Office 365: move domain from tenant to tenant

If you play around with test domains and test tenants, it might be hassle to keep track of which domain is connected to what tenant. Until recent, you just didn’t know. Today I was playing with one of my test tenants again and I wanted to connect a domain to a new tenant. I knew this domain was already used and I feared that a support call was necessary to release this domain. BUT since there are a lot of changes made in the last few week to Office 365, I have new motto, try first, you never know they changed something.

Guess what, they changed something and I got the tenant name where my test domain was connected to … another happy camper.

2013-09-10_1509

 

So you go in your tenant and you try to delete your domain. If your domain is still used as a part of a upn or as a sip address you might have to do some deleting or rename users. If you delete users, make sure to delete them from the recycle bin as well.

To Change the UPN to a <tenant>.onmicrosoft.com

Connect-MsolService

Get-MsolUser | Where { -Not $_.UserPrincipalName.ToLower().StartsWith(“admin@”) } | ForEach { Set-MsolUserPrincipalName -ObjectId $_.ObjectId -NewUserPrincipalName ($_.UserPrincipalName.Split(“@”)[0] + “@<tenant>.onmicrosoft.com”) }

 

To remove users

Get-MsolUser | Where { $_.UserPrincipalName.ToLower().EndsWith(“@contoso.com”) } | Remove-MsolUser

Get-MsolUser -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin –Force

Leave a Reply