Home » PowerShell » Get AdUser Multiple Users Properties

Get AdUser Multiple Users Properties

Using the Get-AdUser cmdlet in PowerShell, we can get multiple user properties. The Get-AdUser cmdlet gets one or more active directory user objects. You can specify multiple adusers in the Get-AdUser to get aduser multiple users properties.

You can retrieve the aduser object and its properties by its samaccountname, distinguishedname, or any other property that identifies the user in the active directory.

In this article, we will discuss how to get aduser multiple users properties using the Get-AdUser cmdlet.

Get Multiple User’s Properties from Active Directory

Use the Get-AdUser LDAPFilter parameter to specify the filter rule, such as samaccountname = toms for multiple adusers, and retrieves the properties for multiple users in PowerShell.

Get-ADUser -LDAPFilter '(|(samaccountname=toms)(samaccountname=chrisd))' |Format-Table Name,DistinguishedName,Enabled,UserPrincipalName

In the above PowerShell script, the Get-AdUser cmdlet uses the LDAPFilter and specifies multiple users condition like |(samaccountname=toms)(samaccountname=chrisd) and passes the output to the Format-Table cmdlet to display multiple user properties in table format.

The output of the above PowerShell script to get aduser multiple user properties is:

Get AdUser Multiple Users Properties
Get AdUser Multiple Users Properties

Get Multiple AdUsers Properties in PowerShell

If you have the list of the samaccountname for multiple users, you can use the Get-AdUser cmdlet to get adusers multiple properties in PowerShell.

 'toms','chrisd' | ForEach-Object { Get-ADUser -Identity $_ -Properties Name,DistinguishedName,Enabled,UserPrincipalName}

In the above PowerShell script, we have specified multiple user samaccountname and piped it as input to the ForEach-Object where it performs the iteration.

The Get-AdUser cmdlet uses the Identity parameter to specify the samaccountname and gets username, aduser distinguishedname, enabled, and aduser userprincipalname.

The output of the above script to get multiple adusers properties in PowerShell is:

PS C:\> 'toms','chrisd' | ForEach-Object { Get-ADUser -Identity $_ -Properties Name,DistinguishedName,Enabled,UserPrincipalName}

DistinguishedName : CN=Tom Smith,OU=SALES,DC=SHELLPRO,DC=LOCAL
Enabled           : True
GivenName         : Tom
Name              : Tom Smith
ObjectClass       : user
ObjectGUID        : 1f3a2572-2621-4e47-9bdf-81d1f8172f69
SamAccountName    : toms
SID               : S-1-5-21-1326752099-4012446882-462961959-1103
Surname           : Smith
UserPrincipalName : [email protected]

DistinguishedName : CN=Chris Dore,OU=SALES,DC=SHELLPRO,DC=LOCAL
Enabled           : True
GivenName         : Chris
Name              : Chris Dore
ObjectClass       : user
ObjectGUID        : ad35249a-e187-4d73-b135-c8fe30729b95
SamAccountName    : chrisd
SID               : S-1-5-21-1326752099-4012446882-462961959-2602
Surname           : Dore
UserPrincipalName : [email protected]

PS C:\>


I hope the above article on how to get aduser multiple user properties in PowerShell using Get-AdUser cmdlet with LDAPFilter parameter is helpful to you.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.