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

Posted on 2011-10-11
Medium Priority
Last Modified: 2012-05-12
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
Question by:GospodinRasputin
  • 2
LVL 39

Accepted Solution

Krzysztof Pytko earned 1000 total points
ID: 36947918
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

and use this syntax

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


Author Comment

ID: 36954587
First option, run from the DC worked like magic. I have not tried the Powershell route.
Thank you
LVL 39

Expert Comment

by:Krzysztof Pytko
ID: 36954600
You're welcome :)


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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question