Say you end up with a wrong UserPrincipalName for an MSOL account which is sync’ed from On-Prem Active Directory like this: firstname.lastname@example.org, Which is obviously wrong UPN. The correct UPN supposed to be like email@example.com and it should match the user’s PrimarySMTPAddress.
I am sure you tried to correct it in Office 365 Admin Center, where UPN is grayed out. You may have tried MSOL PowerShell command Set-MSOLUser which does not have the parameter -UserPrincipalName. Right? That why you are here.
Solution: Easy Peacy. You have to use the another MSOL PowerShell command like this:
Set-MsolUserPrincipalName -UserPrincipalName firstname.lastname@example.org -NewUserPrincipalName email@example.com
That’s it. You have done it. Have an coffee! You deserve it! 🙂