Active Directory Naming Conversion using Powershell
When dealing with Exchange, most of the object Identities are in the form of CanonicalName which makes searching Active Directory difficult since Canonical Name is a calculated attribute and cannot be used in a query. For example, the identity of a mailbox is the cn of the user: [PS] C:\Windows\system32>$cn = (get-mailbox cpolydorou).Identity.ToString() [PS] C:\Windows\system32>$cn LAB.local/LAB/Users/Christos Polydorou The newly released version of my Active Directory module ( 1.3.0 ) contains the cmdlet "Convert-ActiveDirectoryNaming" that will help with converting between the different Active Directory naming formats. The following example illustrates the usage of the cmdlet. First, let's get the user from Active Directory in order to have the DistinguishedName, SamAccountName, CanonicalName and UserPrincipalName values. PS C:\> $user = Get-ADUser cpolydorou -Properties DistinguishedName, SamAccountName, CanonicalName, UserPrincipalName P...