Find-ADUser

Finds a user in Active Directory.

Syntax

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

Description

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

Parameters

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.

EXAMPLE 1

Find-ADUser -DomainUrl LDAP://dc.example.com:389 -sAMAccountName $env:USERNAME

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