During one Office 365 tenant-to-tenant migration I was doing, I needed to remove all references of the vanity domain from the source tenant before being able to remove the domain to then add it to the destination tenant.
No matter what I tried, I couldn’t get one AD-synced user’s UPN to no longer include the vanity name. Changing their UPN in AD to the .local and running a “Start-ADSyncSyncCycle” didn’t change their 365 UPN to the onmicrosoft.com UPN as expected.
I ended up fixing it by running the Set-MsolUserPrincipalName command.
First, change their UPN in AD to a non-syncing UPN (for example, acme.local or whatever their internal domain name is).
Then, run this command:
Set-MsolUserPrincipalName -UserPrincipalName "[email protected]" -NewUserPrincipalName "[email protected]"
Obviously, the UPN you’re changing it to needs to exist in the tenant. So, change it to either its onmicrosoft.com UPN or to a vanity domain that is present in the tenant.
After that – you’re done! The user now how the correct UPN and in our example we’ll now be able to remove the domain. Read my article here on how to remove domains quickly and easily via PowerShell.
Jason works as a project specialist at an IT MSP in Erie, Pennsylvania, USA. He’s an IT/security professional with 19 years experience.