Finds a user in Active Directory.


Find-ADUser -DomainUrl <String> -sAMAccountName <String> [<CommonParameters>]


Searches the Active Directory domain given by DomainUrl for a user whose sAMAccountName matches the sAMAccountName passed in. Returns the DirectoryEntry object for that user. If there are any errors communicating with the domain controller, $null is returned.

Related Commands


Name Type Description Required? Pipeline Input Default Value
DomainUrl String

The LDAP URL to the domain controller to contact.

true false
sAMAccountName String

Search by a user's sAMAcountName (i.e. Windows username). Special characters are escaped.

true false

Return Values

System.DirectoryServices.DirectoryEntry. The directory entry object of the user's account in Active Directory or $null if the user isn't found.


Find-ADUser -DomainUrl LDAP:// -sAMAccountName $env:USERNAME

Finds the AD user whose Windows username (sAMAccountName) is equal to thecurrently logged on user's username.