19 April 2012

Retrieve active directory user OU.

User's organizational unit information can be easily extracted from user's DistinguishedName ldap attribute:

$user = Get-ADUser marius.dumitru
$ou = $user.DistinguishedName.Substring($user.DistinguishedName.IndexOf("OU="))

result:

OU=Some users,DC=domain,DC=intra

No comments:

Post a Comment