Home » PowerShell » Get AdUser DistinguishedName in Active Directory

Get AdUser DistinguishedName in Active Directory

A Distinguished Name (DN) in the Active Directory uniquely identifies an object in the directory. To get aduser distinguishedname, use the Get-AdUser cmdlet with its DistinguishedName property.

In the active directory, the distinguished name (DN) is a sequence of relative distinguished names (RDN) connected by commas. For example, CN=Tom Smith,OU=SALES,DC=SHELLPRO,DC=LOCAL

In this article, we will discuss how to get aduser distinguishedname in the active directory using the Get-AdUser cmdlet.

Get AdUser DistinguishedName

Use the Get-AdUser cmdlet in PowerShell to get one or more active directory users. It gets the default set of aduser properties.

You can get aduser distinguishedname in a default set of properties or you can specify the distinguishedname property.

Get-ADUser -Identity Toms

In the above PowerShell script, the Get-AdUser uses the Identity parameter to specify the user and retrieves aduser object properties like aduser distinguishedname, name, userprincipalname, etc…

The output of the above PowerShell script to get a distinguishedname for a user is a sequence of relative distinguished names separated by commas (,) like CN=Tom Smith,OU=SALES,DC=SHELLPRO,DC=LOCAL

PS C:\> Get-ADUser -Identity Toms


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]

Get DistinguishedName for AdUsers in Active Directory

You can get distinguishedname for adusers in the active directory using the Get-AdUser Filter * parameter to retrieve all the adusers distinguished names.

Get-ADUser -Filter * | Select Name, DistinguishedName

In the above PowerShell script, the Get-AdUser cmdlet uses a Filter parameter with a wildcard (*) to get a distinguished name for all adusers in the active directory.

The output of the above script to get adusers distinguishedname is:

Get AdUser Distinguished Name
Get AdUser Distinguished Name

Conclusion

I hope the above article on how to get aduser distinguished name in the active directory is helpful to you.

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