How do I extract Display Names from AD if I know the username

I have a list of usernames (300 usernames), but wish to have the display names. I do not want to go through AD clicking on each account to copy the display name as this will take forever for the 300 accounts I have.

So I need a way to query AD and supply the usernames so it can retrieve the display names.
Thank you
Gospodin RasputinIT ManagerAsked:
Who is Participating?
 
Krzysztof PytkoConnect With a Mentor Senior Active Directory EngineerCommented:
For that yiu can use standard DS Tools or Quest PowerShell module for AD. For the first option you need to run query on a DC or workstation with Administrative Tools installed. Make sure that each username is in separate line and run in command-line

for /f %i in (c:\users.txt) do dsquery user -samid %i | dsget user -samid -fn -ln -display >>c:\display.txt

to get it running on PS, download Quest PS from
http://www.quest.com/powershell/activeroles-server.aspx

and use this syntax

Get-Content c:\users.txt | %{ Get-QADUser $_ | Select sAMAccountName,givenName,sn,display } | Export-CSV c:\display.csv

Regards,
Krzysztof
0
 
Gospodin RasputinIT  ManagerAuthor Commented:
First option, run from the DC worked like magic. I have not tried the Powershell route.
Thank you
0
 
Krzysztof PytkoSenior Active Directory EngineerCommented:
You're welcome :)

Krzysztof
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.