HOWTO: Get-ADUser for Display Names

When working with Active Directory from PowerShell, you’ll often find yourself using the Get-ADUser cmdlet.  You’ll find yourself often looking up user accounts by typing something like Get-ADUser jsmith which works just fine as jsmith is the samaccountname for a user in Active Directory.  But what happens if you want to look up by Display Name?  Or more commonly, you are given a list of employees in a CSV and you need to look up those AD accounts. You’ll find that if you try to supply the Display name field in the same way, you’ll get an “Object not found” error.  Example:

Get-ADUser jsmith <- Works
Get-ADUUser “John Smith” <- Fails

So, how do you use the Get-ADUser cmdlet to look up users if all you have is their display name?  Like this:

Get-ADUser -Filter{ DisplayName -eq “John Smith” }

 

It has come up enough times I stumble over myself each time that I figured other people must be having the same challenge so I figured I’d document it.

 

1 comments

    • Chris on December 1, 2016 at 8:51 pm
    • Reply

    Thank you! I’ve been trying to figure this out and all the examples I find are way more complicated than I needed, such as how to do entire lists and filter a billion different things I don’t need. I just needed a simple solution to find one user by display name. Microsoft TechNet articles are so dense and hard for me to understand.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.