There are multiple good PowerShell options to query an Active Directory user object. Below are three code snippets which all locate an AD user. Cheers!
Option 1- Get-ADUser Login
Get-ADUser jsmith -Properties *
Option 2- Get-ADUser Filter
Get-ADUser -Filter {Surname -like 'W*'} -Properties *
Option 3 – LDAP Directory Searcher
$strFilter = "(&(objectCategory=User)(samAccountName=jsmith))" $objDomain = New-Object System.DirectoryServices.DirectoryEntry $objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.SearchRoot = $objDomain $objSearcher.PageSize = 1000 $objSearcher.Filter = $strFilter $objSearcher.SearchScope = "Subtree" $colProplist = "name" foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)} $colResults = $objSearcher.FindAll() foreach ($objResult in $colResults){$objItem = $objResult.Properties; $objItem.name}
Option 4 – DSA.MSC
- Open Active Directory Users and Computers.
- Right-click the domain object and select Find.

- Active Directory Users and Computers Select Find
- Click the drop-down list next to Find, and then select Custom Search.

- From the next screen, select the Advanced tab.
- Type the appropriate LDAP statement under Enter LDAP query.
Option 5 – LDP.EXE
- Download from https://www.microsoft.com/en-us/download/details.aspx?id=15326
- On the Browse menu, click Search.
- The Search dialog box opens.
- To search for all users that have a first name of John and a last name of either Smith or Jones, type the following in the Filter field:
- (&(objectClass=user)(givenName=John)(|(sn=Smith)(sn=Jones))))
