< Back

Find-CADUser

Sun Jan 12, 2020 9:30 pm

NAME Find-CADUser



SYNOPSIS

Finds a user in Active Directory.





SYNTAX

Find-CADUser -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.





PARAMETERS

-DomainUrl <String>

The LDAP URL to the domain controller to contact.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-sAMAccountName <String>

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

characters are escaped.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

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 --------------------------



PS C:\\>Find-CADUser -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.











RELATED LINKS

http://msdn.microsoft.com/en-us/library/aa746475.aspx