Tuesday, November 13, 2018

Migrate mails from Office 365 tenant to tenant

Migrate mails between two Office 365 tenants while keeping the same domain name  ie: move a domain from one tenant to another.

1. Mailbox migration

migrate your mailboxes from domain.com (tenant 1) to tenant2.onmicrosoft.com (tenant 2).
Choose a big bang migration:

2. Mail routing

provides a mail routing platform that forwards mails from domain.com (your domain) to tenant2.onmicrosoft.com
The transition will be transparent.
When you are ready to detach your domain, switch your MX records and point to domain.com mail routing platform.
Note: At the beginning of your migration, decrease the TTL of the MX record to the minimal value, so that there will be no caching issue when you will switch your MX records.
Every incoming mail for user@domain.com will be delivered transparently to user@tenant2.onmicrosoft.com
Therefore, even if it takes a few days to detach your domain, mail delivery will be performed transparently and the mails will be delivered to the target mailboxes even if the domain is not attached yet to the target tenant.

3. Domain detach

Activate the target tenant domain and to detach your domain from the source tenant.
You must first remove all the primary SMTP addresses and aliases that reference your domain company.com.

4. Rename users

Here is an example PowerShell script that modifies all mail addresses.

Get-MsolUser | ForEach { Set-MsolUserPrincipalName -ObjectId $_.ObjectId -NewUserPrincipalName ($_.UserPrincipalName.Split(“@”)[0] + “@sourcedomain.onmicrosoft.com”) }
  1. Set the Azure AD Logon UPN Domain to @domain.onmicrosoft.com
  2. Set the Default Mail Address for users to @domain.onmicrosoft.com
  3. Remove all alias Email Addresses
  4. Set Groups, Shared Mailboxes, and Resources primary SMTP Address to @domain.onmicrosoft.com
Once there are no more accounts that keep a reference to the source domain, Office 365 lets you detach the domain from the tenant ( Admin -> Office365 -> Domains -> Delete a domain )
the domain is being detached but cannot be reattached yet in the target tenant (because it still “belongs” to the source tenant).
Therefore, your users can start using the target mailboxes but they must use user@tenant2.onmicrosoft.com to login to the target.
If the transition is performed during a weekend, we recommend the users to login temporarily using OWA with the onmicrosoft.com UPN at the target (this will avoid a double Outlook reconfiguration).

5. Wait for the replication delay to expire.

Once the domain is free, you can reattach it to the target tenant.
In the Office 365 admin portal, go to Admin -> Office365 -> Domains -> Add a domain

6. DNS settings

Set the txt verification record.

7. Run The AAD connect to Sync the accounts to new target domain.

8. Reassign all your users their primary SMTP address.

Identity Management to set the primary SMTP address to their original value, Once all users have their UPN set to the .onmicrosoft.com domain, you will need to remove any email address using one of your domains. You will have to perform this cleanup on users, groups, and resources (room and equipment).
Set the Azure AD Logon UPN Domain to @tenant2.com
Set the Primary SMTP Addresses to @tenant2.com
Get-MsolUser -DomainName tenant2.com -all

9. Prepare Migration of Delta email Data

Source username@tenant1.onmicrosoft.com target username@tenant2.onmicrosoft.com

10. Change your MX records.

You can now point your MX records to the target Office 365 tenant

No comments:

Post a Comment