AD query

Soldato
Joined
18 Oct 2002
Posts
4,619
hi

i have a list (in excel format) of a load of my users proper names

any way i can extract their usernames from AD quickly and easily? there are 900 of them!

thanks!
 
You could just create a query from an AD console. This could output the user names and the name of the user so you wouldn't have to update your spreadsheet at all.
 
You could just create a query from an AD console. This could output the user names and the name of the user so you wouldn't have to update your spreadsheet at all.

surely this would just dump all the users (for a given OU)?

i want to get a subset of users from several OUs
 
surely this would just dump all the users (for a given OU)?

i want to get a subset of users from several OUs

You can select a specific OU from the query builder if you need to. I don't think there is an option to select more than one though.
 
Last edited:
Can you not just export the entire OU/OUs and delete what you dont want?

If so use csvde:

CSVDE -d "OU=User OU,DC=domain,dc=local" -l "givenName, sn, sAMAccountName" -r "(objectClass=user)" -f export.csv

Will go nicely into your Excel sheet
 
we're looking for about 900 users from maybe 10000

i've passed the case over to our AD team now anyway - thanks for all your help
 
Adfind and a batch file would do it.


As an example we had a load of old NT4 SIDs we wanted to look up against SID history in AD to see what the new AD group was.

just had a list of SIDs in a text file, in your case this would be the users names.

and then...

for /f "delims=" %%A in (%1) do adfind -b "OU=???,DC=???,DC=???,DC=???" -s subtree -f "&(sidhistory=%%A)" cn sidhistory -adcsv | find "," >> %1.sidh2cn.%DATE:/=-%.txt

so for yours, you'd need to change

(sidhistory=%%A)

to search against the users full name, and then the bits after that...

cn sidhistory

are the values you want returned. the

-adcsv

tells it to output the results as csv and then the

>> %1.sidh2cn.%DATE:/=-%.txt

is the results file you are piping out to.
 
Back
Top Bottom