
This command gets all users that have a name that ends with SvcAccount. Example 2: Get a filtered list of users PS C:\> Get-ADUser -Filter 'Name -like "*SvcAccount"' | Format-Table Name,SamAccountName -A This command gets all users in the container OU=Finance,OU=UserAccounts,DC=FABRIKAM,DC=COM. Examples Example 1: Get all of the users in a container PS C:\> Get-ADUser -Filter * -SearchBase "OU=Finance,OU=UserAccounts,DC=FABRIKAM,DC=COM"
POWERSHELL LDAP QUERY USER HOW TO
To retrieve additional properties use the Properties parameter.įor more information about how to determine the properties for user objects, see the Properties parameter description. This cmdlet retrieves a default set of user object properties. If you have existing Lightweight Directory Access Protocol (LDAP) query strings, you can use the LDAPFilter parameter. PowerShell Expression Language syntax provides rich type-conversion support for value types received by the Filter parameter.įor more information about the Filter parameter syntax, type Get-Help about_ActiveDirectory_Filter. The Filter parameter uses the PowerShell Expression Language to write query strings for Active Directory. To search for and retrieve more than one user, use the Filter or LDAPFilter parameters. You can also set the parameter to a user object variable such as $ or pass a user object through the pipeline to the Identity parameter. You can identify a user by its distinguished name (DN), GUID, security identifier (SID), or Security Account Manager (SAM) account name. The Identity parameter specifies the Active Directory user to get. The Get-ADUser cmdlet gets a specified user object or performs a search to get multiple user objects.
