Link to home
Start Free TrialLog in
Avatar of JJ KR
JJ KRFlag for India

asked on

ACtive Directory security Group

Dear Experts,

I can export and import active directory users using csvde utility. But my Organization wants export and import the security group of ROLES OU Under Test OU.along with members associated with that group. Please find the attUser generated imageaches snap for reference .
20151115_222509.jpg
20151115_222509.jpg
Avatar of Benjamin Voglar
Benjamin Voglar
Flag of Slovenia image

you can export group mambers with powershell:

Get-ADGroupMember -identity “Name of Group” | select name | Export-csv -path C:\Output\Groupmembers.csv
Just use powershell for this. See below..
Get-ADGroup -Filter * -searchbase "ou=roles,ou=test,dc=cb,dc=gov.dc=qa" | 
Get-ADGroupMember | 
Select @{n=GroupName';e={ (get-adgroup -identity $_) } }, Name
 

Open in new window


The script above will get all of the groups in the OU and show all of the members for each group it finds.

Will.
Avatar of JJ KR

ASKER

Hi,

Thanks for the comments i git this error while executing

PS C:\> Get-ADGroupMember -identity "ADMIN" | select name | Export-csv -path C:\Output\Groupmembers.csv
The term 'Get-ADGroupMember' is not recognized as the name of a cmdlet, function, script file, or operable program. Che
ck the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:18
+ Get-ADGroupMember <<<<  -identity "ADMIN" | select name | Export-csv -path C:\Output\Groupmembers.csv
    + CategoryInfo          : ObjectNotFound: (Get-ADGroupMember:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Go on Domain Controler and run powershell with modules
Or run powershell and run this command first:

Import-Module ActiveDirectory
Yes you need to have the activedirectory module imported first before running the script.

Will.
Avatar of JJ KR

ASKER

Thanks Benjamin Voglar and thanks wills I will test and let you know.
Avatar of JJ KR

ASKER

HI Benjamin Voglar,

I ran the command as instructed by you and the csv file generated without any records. Output.csv 0KB

PS C:\Users\Administrator>  Get-ADGroupMember -identity "ADMIN" | select name | Export-csv -path C:\Output\Groupmembers.
Avatar of JJ KR

ASKER

Dear Will Szymkowski,
I ran the command as per your instruction but no results.
PS C:\Users\Administrator> Import-Module ActiveDirectory
PS C:\Users\Administrator> Get-ADGroup -Filter * -searchbase "ou=roles,ou=test,dc=cb,dc=gov.dc=qa" |
>>
ASKER CERTIFIED SOLUTION
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JJ KR

ASKER

Hi , I ran this script
 Get-ADGroup -Filter * -searchbase "ou=roles,ou=test,dc=cb,dc=gov.dc=qa" |
Get-ADGroupMember |
Select @{n=GroupName';C={ (get-adgroup -identity $_) } }, Name
 
And getting this error

The string starting:
At C:\Users\Administrator\Desktop\script.ps1:3 char:21
+ Select @{n=GroupName <<<< ';C={ (get-adgroup -identity $_) } }, Name
is missing the terminator: '.
At C:\Users\Administrator\Desktop\script.ps1:5 char:1
+  <<<<
    + CategoryInfo          : ParserError: (;C={ (get-adgro... } }, Name

:String) [], ParseException
    + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString