Easy way to get Display name from list of UserID’s from AD

This is a quick one line command that I created to return a list of Display names when all I had was UserID’s.

It’s a simple DSQUERY command piped into a DSGET to return the Display Name and SAMID of the user. Just have a look of at the DSGET command you can see all the different attributes that i can return for you.

First you need a text file with UserID’s one per line. Then just open a command prompt in the same directory where you have the text files and run this command, don’t forget to change the USERID.TXT to the name of your text file:
 

FOR /F %i in (userid.txt) DO DSQUERY user -samid %i | DSGET user -display -samid >> displayname.txt

You’ll now find a text file in that directory named displayname.txt with all your Display Names.