Ok thanks but when I try that I got an error:
Update-MgUser -OnPremisesImmutableId BoIXHkBlM064in432nqicA== -UserId abc@Company portal .com
Update-MgUser_UpdateExpanded: One or more properties contains invalid values.
I tried changing permissions to User.ManageIdentities.All but same error. I find if I change UPN from Federated to Managed it works ok, but I was hoping to avoid that step, but...
this eventually worked for me - prep a CSV with UPN1 (user@*mydomain.com), UPN2 (user@*.onmicrosoft.com), ImmutableId
Get-Content -Path {csv file path}| ConvertFrom-Csv | foreach { Update-MgUser -UserId $_.UPN1 -UserPrincipalName $_.UPN2 -OnPremisesImmutableId $_.ImmutableId }
# Same CSV
Get-Content -Path {csv file path}| ConvertFrom-Csv | foreach { Update-MgUser -UserId $_.UPN2 -UserPrincipalName $_.UPN1 }
So, step 1, move from Fed to Managed domain and overwrite new ImmutableId; step 2 immediately move back to Fed domain.
I'm sure some PS guru could do this in one line?
Thanks for pointing me in the right direction.