Forum Discussion

stylz1's avatar
stylz1
Copper Contributor
Apr 01, 2021

Change email alias to on.microsoft.com account as primary

Hi,

I'm performing an O365 tenant-to-tenant migration. I need to remove the domain name for the source domain and register and verify it in the destination domain. I'd like to make sure that all users using the alias domain I'm migrating to the new tenant say (@testdomain.com) to be set to use (@testdomain.onmicrosoft.com) as their primary address in the source tenant so that I can move the alias.

I'd like a script that lists all accounts using @testdomain.com as primary and change it to @testdomain.onmicrosoft.com 

so far I've come across two scripts that do both parts but I'd like assistance with making it one complete script. The two scripts I've come across are below. If there is a better way of doing this please let me know:

 

Get-MsolUser -DomainName Fabrikam.com -All

 

Set-MsolUserPrincipalName -UserPrincipalName user@testdomain.com -NewUserPrincipalName user@testdomain.onmicrosoft.com

 

1 Reply

  • Seshadrr's avatar
    Seshadrr
    Iron Contributor
    Microsoft has defined a script from one Microsoft 365 or Office 365 organization to another. Please refer if it suitable for your requirement.

    https://docs.microsoft.com/en-us/exchange/mailbox-migration/migrate-mailboxes-across-tenants

Resources