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

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,
jgrammer42Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Farhan KaziSystems EngineerCommented:
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

0
jgrammer42Author 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,
0
Farhan KaziSystems EngineerCommented:

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

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

jgrammer42Author 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?

0
Farhan KaziSystems EngineerCommented:
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

0
jgrammer42Author 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?

0
Farhan KaziSystems EngineerCommented:
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

0
jgrammer42Author 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.
0
Farhan KaziSystems EngineerCommented:
Distinguished Name of the group must be wrong!!!
Apply following statement to get correct group DN



DSQuery Group -Name PAYROLL

Open in new window

0
jgrammer42Author 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!

0
jgrammer42Author Commented:
Slight error in AD directory pathing on my part.  Original answer was 100% correct.
0
Raja BSystem EngineerCommented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Active Directory

From novice to tech pro — start learning today.