There’s been a long-standing issue with Office 365 where you cannot change a user’s userPrincipalName (UPN) from one federated domain to another. When attempting to make a UPN change between two federated
domains, the tenant’s technical contact will receive a “Directory Synchronization Error Report” email which contains the
new userPrincipalName and the user’s immutableID.
In order to remediate the issue, we need the user’s old userPrincipalName; this script helps with getting the proper value and making the necessary change.