[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 22545
  • Last Modified:

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,
0
jgrammer42
Asked:
jgrammer42
  • 6
  • 5
1 Solution
 
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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

Featured Post

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.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now