powershellactive-directorywindowsdomainaccount

Powershell Search for AD Users


I am learning Powershell and use it frequently for adding users to AD Groups. I would like to know if it is possible to search for AD Usernames using the persons common name (i.e. John Doe = JDoe). It is very time consuming and defeats the purpose of using Powershell if I have to use AD Users and Computers to look up their UID every time.

UPDATE: I tried the Get-ADUser -filter { cn -eq 'John Doe' } and Get-ADUser -filter { Name -eq 'John Doe' } command and I did not receive any output from the console, it immediately went to the next line.

I also have RSAT installed, just to clarify. I have looked at the technet article on MS' page Get-ADUser to try and figure it out before I posted the OP.

Just to clarify I am looking to search by the Common Name to find that user's Login Name. i.e. Searching 'John Doe' to find 'jdoe' the User Logon Name.


Solution

  • Yes. You need to install RSAT. See here for instructions for various Windows versions.

    Then use Get-ADUser:

    Get-ADUser -filter { cn -eq "Common Name" }