A userPrincipalName (UPN) must be unique in a Active Directory Forest. To check for an existing UPN use the following lines. The powershell script expects that all DC’s within the Root Domain are GC enabled .
$RootDomain = "Contoso.com" $DomainControllerRoot = (Get-ADDomainController -Filter * -server $RootDomain | select Hostname).hostname[0] $GlobalCatalog = $DomainControllerRoot +":3268" $UserPrincipalName = "Name@namespace.com" if ((get-aduser -ldapfilter "(userPrincipalName=$UserPrincipalName)" -server $GlobalCatalog ).userPrincipalName.length -gt 0) { Write-host "UPN NOT unique in Forest : $UserPrincipalName " } Else { Write-host "UPN UNIQUE in Forest : $UserPrincipalName " } |