You need to remove all UPN suffixes from AD if ( -not ( Get-Module ActiveDirectory ) ) {
Import-Module ActiveDirectory
}
$domain = [System.DirectoryServices.ActiveDirectory.Domain] :: GetCurrentDomain ( )
$domaindn = ( $domain . GetDirectoryEntry… Read the full text.