Jump to content

Recommended Posts

Posted

Hi All,

 

Is there any way to export data from the AD. I would like to export all staff members and their groups assigned to them.

 

Any advice would much great

 

 

 

Faza

Posted (edited)

I've bodged this script together:

 

dsquery user "OU=Staff,DC=blah,DC=sch,DC=int" -limit 3 > userlist-output.txt
for /f "tokens=*" %%i in (userlist-output.txt) do @echo ------ >> groups-output.txt && dsget user %%i -q -L -samid -display >> groups-output.txt && @echo ------ >> groups-output.txt && echo Groups: >> groups-output.txt && dsget user %%i -memberof -expand >> groups-output.txt && @echo ------ >> groups-output.txt
findstr -iV "dsget" groups-output.txt > groups-output2.txt
move /Y groups-output2.txt groups-output.txt
notepad groups-output.txt

 

"OU=Staff,DC=blah,DC=sch,DC=int" would have to be changed to the full path to your staff OU. I'm not sure if you need the adminpak installed on XP to have access to dsget and dsquery. 2003 should have them by default though.

 

It will expand group memberships, so if they are a member of GTP-TRAINEES and that group is a member of TEACHERS it should list both. That means it can be slow to run, so get it working nicely then change the limit from 3 to 1000 and go make a brew.

Edited by sahmeepee
tarted up output a little

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • 43 When would you like EduGeek EDIT 2025 to be held?

    1. 1. Select a time period you can attend


      • I can make it in June\July
      • I can make it in August\Sept
      • Other time period. Comment below
      • Either time

×
×
  • Create New...