How to Add Alternative UPN and Change Default UPN
Imagine the scenario that you need to add an alternative UPN to your active directory, this may as you have a “.local” domain and you need to federate withy our O365 environment and that is a “.COM” domain. As you may not know it makes for best practise to have your UPN match your login details in O365 to make single sign on place nice.
Below I show you first of all the steps to add an alternative UPN and then the Powershell to change the UPN globally.
Add Alternative UPN to Active Directory
- Open Active Directory Domains and Trusts.
- Right click Active Directory Domains and Trusts and Select “Properties”.
- On the UPD suffix add the domain UPN you would like to use.
Change UPN Globally in Powershell for All Users
With the powershell below simple change the “.Local” domain and the “.Com” domain to match your needs.
$LocalUsers = Get-ADUser -Filter {UserPrincipalName -like '*internal.local'} -Properties userPrincipalName -ResultSetSize $null $LocalUsers | foreach {$newUpn = $_.UserPrincipalName.Replace("internal.local","external.com"); $_ | Set-ADUser -UserPrincipalName $newUpn}
Tags: 365, Active directory