Office 365- Change UPN in 365 from PS

Last updated on March 26th, 2018 at 09:35 am

If DirSync can`t sync changes of username in 365 after changes in premised AD with 365 few steps to solve problem.
AD user is [email protected]
365 user is [email protected]
DirSync can sync smtp address but not the User and nothing happening after 48 hours
Step 1 – Connect to 365 Power Shell



$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $UserCredential -Authentication Basic –AllowRedirection
Import-PSSession $Session

Step 2 – Run Command
Set-MsolUserPrincipalName -UserPrincipalName [email protected] -NewUserPrincipalName [email protected]
Get-MsolUser -UserPrincipalName [email protected] | Set-MsolUserPrincipalName -NewUserPrincipalName [email protected]