We help IT Professionals succeed at work.

Can I use CSVDE to export the users in a specific group from AD?

jgrammer42
jgrammer42 asked
on
I have a need to export the user information, from several specific Distribution Groups under Active Directory.

I know I can export this information using CSVDE at the command line.  But I only know how to export the group level information, not the MEMBERS of that specific group.

For example,  say we have the domain name of NETDOMAIN.com  Under that domain, I have an OU called MYCOMPANY and under that a  group called PAYROLL which has both AD users and Contacts users in it.  I want to export the members of that group, and ONLY that group, and not the whole AD/LDAP directory information.  If I use the CSVDE command parms of

csvde -d "OU=MYCOMPANY,DC=lou,DC=NETDOMAIN,DC=com" -r objectClass=group -f companywidegroup-emails.csv

That only gives me the group level information for the groups listed underneath MYCOMPANY, but I want to get the 'member' information of the specific group called PAYROLL.

Does anyone know the csvde command line parms to do this?

Thank you,
Comment
Watch Question

Farhan KaziSystems Engineer
BRONZE EXPERT
Top Expert 2007

Commented:
Try this:
CSVDE -d "OU=MYCOMPANY,DC=NETDOMAIN,DC=COM" -r "(&(objectClass=Group)(name=PAYROLL))" -l Member -f companywidegroup-emails.csv

Open in new window

Author

Commented:
That is pretty close.  The only thing though is that it outputs the contents into one comma delimited field, and does not include other information that would be great to have like the email address.

Is there a way to export that data also, and split it out into separate fields so that it can easily be imported into a spreadsheet?

Thank you,
Systems Engineer
BRONZE EXPERT
Top Expert 2007
Commented:

CSVDE -R "(&(objectCategory=user)(memberOf=CN=PAYROLL,OU=MYCOMPANY,DC=NETDOMAIN,DC=COM))" -L mail -F companywidegroup-emails.csv

Open in new window

Author

Commented:
Hmmm....that returned zero entries.  Is the syntax of "memberof=CN=" correct?  Should there be any quotes around the CN, OU and DC entries?

Farhan KaziSystems Engineer
BRONZE EXPERT
Top Expert 2007

Commented:
Syntax is correct.
Try following statement and post results.

DSQuery * -Filter "(&(objectCategory=user)(memberOf=CN=PAYROLL,OU=MYCOMPANY,DC=NETDOMAIN,DC=COM))" -Attr Name mail -limit 0

Open in new window

Author

Commented:
I used the command:
DSQuery * -Filter "(&(objectCategory=user)(memberOf=CN=Payroll,OU=MYCOMPANY,DC=NETDOMAIN,DC=com))" -Attr Name mail -limit 0

And no output was generated.

What should I have expected to see?

Farhan KaziSystems Engineer
BRONZE EXPERT
Top Expert 2007

Commented:
Strange! Above command should show user's full name with email addresses.
Try this:
Click Start -> Run -> Cmd.exe ->

DSGet Group "CN=PAYROLL,OU=MYCOMPANY,DC=NETDOMAIN,DC=COM" -members|DSGet user -dn -email

Open in new window

Author

Commented:
Here is what I get using that command:

C:\Data\Exchange Info>DSGet Group "CN=PAYROLL,OU=MYCOMPANY,DC=NETDOMAIN,DC=
COM" -members|DSGet user -dn -email
dsget failed:Directory object not found.
type dsget /? for help.dsget failed:`Target object for this command' is missing.

type dsget /? for help.

yeah, kind of odd.....because it obviously DOES exist because the very first command you had me try did work, just did not pull all the info I wanted.

Oh well, this really is not a big deal, I was just trying to make it easier on myself, rather than having to "hand check" all of the members in the group.
Farhan KaziSystems Engineer
BRONZE EXPERT
Top Expert 2007

Commented:
Distinguished Name of the group must be wrong!!!
Apply following statement to get correct group DN



DSQuery Group -Name PAYROLL

Open in new window

Author

Commented:
You are absolutely correct....I was missing a level in between!

There was another OU level (Groups), between the OU=MYCOMPANY.  I change your original CSVDE command of
CSVDE -R "(&(objectCategory=user)(memberOf=CN=PAYROLL,OU=MYCOMPANY,DC=NETDOMAIN,DC=COM))" -L mail -F companywidegroup-emails.csv

to read

CSVDE -R "(&(objectCategory=user)(memberOf=CN=PAYROLL,OU=GROUPS, OU=MYCOMPANY,DC=NETDOMAIN,DC=COM))" -L mail -F companywidegroup-emails.csv


And it gave me back exactly what I was looking for.

Thanks!

Author

Commented:
Slight error in AD directory pathing on my part.  Original answer was 100% correct.
Raja BSystem Engineer

Commented:
I used  below command to its working fine  to export members of one group.

BUT MY OBJECTIVE is, I have a list of 20 SL group names, Need to verify if user is a member of  any one of these group, IF yes it should list the group names,

Please help

CSVDE -R "(&(objectCategory=user)(memberOf=CN=groupname,OU=GROUPS,DC=xxx,DC=XYZ,DC=NET))" -L samaccountname -F companywidegroups.csv