Remove a domain from Microsoft 365
At the end the domain will be gone from your tenant, with every user name, email address, group and app moved to another domain first, so it can be added to another tenant or service.
What you need before step 1
Applies to: Microsoft 365 and Microsoft Entra ID custom domains, as documented by Microsoft
Admin roles you need
- Domain Name Administrator (least privileged role Microsoft lists for deleting a domain) or Global Administrator, signed in with an account that is NOT on the domain being removed
- User Administrator (or higher) to change user names
- Exchange Administrator to change mailbox and group email addresses
- Application Administrator to change app ID URIs, if any apps use the domain
Licences
None needed.
Install instructions
https://learn.microsoft.com/en-us/graph/sdks/sdk-installationOur step-by-step →Install stepshttps://learn.microsoft.com/powershell/exchange/exchange-online-powershell-v2Our step-by-step →Install stepsAlso have ready
- Another verified domain (or contoso.onmicrosoft.com) to move users and addresses to
- If users are synchronised from on-premises Active Directory, access to change their UPNs and proxy addresses there
- A list of what uses the domain outside Microsoft 365 (MX, SPF, websites) so you know the mail flow impact
9 steps
- 1
Sign in with an account on another domain
Where: Microsoft 365 admin center, in a private browser windowSign in as an admin whose user name is on the
.onmicrosoft.comdomain or another custom domain, for exampleadmin@contoso.onmicrosoft.com. Microsoft says you cannot delete a domain referenced in your own account name. If you are the only Global Administrator on the domain, create another Global Administrator on a different domain first.You should see: You are signed in as an admin not on the domain you are removing. - 2
Change the default domain if needed
Where: Microsoft 365 admin center > Settings > Domains, or Microsoft Graph PowerShellThe domain being removed cannot be the default. Select another domain and set it as default, or use PowerShell.
Connect-MgGraph -Scopes "Domain.ReadWrite.All","User.ReadWrite.All","Group.Read.All","Application.Read.All" Update-MgDomain -DomainId fabrikam.com -IsDefaultYou should see: The Domains page shows another domain marked Default. - 3
List every object that still references the domain
Where: PowerShell on your admin computer, connected with Connect-MgGraphAsk Graph which users, groups and other objects reference the domain, then find users by sign-in name, mail or proxy address, and apps whose identifier URIs use it.
Get-MgDomainNameReference -DomainId contoso.com -All | Format-List Id,AdditionalProperties Get-MgUser -All -Property Id,UserPrincipalName,Mail,ProxyAddresses | Where-Object { $_.UserPrincipalName -like "*@contoso.com" -or ($_.ProxyAddresses -match "@contoso.com") } | Select-Object UserPrincipalName,Mail Get-MgApplication -All | Where-Object { $_.IdentifierUris -match "contoso.com" } | Select-Object DisplayName,IdentifierUrisYou should see: A list of the users, groups and apps you must change. The goal is for all three commands to return nothing. - 4
List every mail recipient that uses the domain
Where: PowerShell connected with Connect-ExchangeOnlineThis catches mailboxes, shared and resource mailboxes, contacts, distribution lists, mail-enabled security groups and Microsoft 365 groups with an address on the domain.
Get-Recipient -ResultSize Unlimited | Where-Object {$_.EmailAddresses -match "contoso.com"} | Format-List Name,RecipientType,EmailAddressesYou should see: Each recipient still using the domain, with its RecipientType. - 5
Move user sign-in names to another domain
Where: PowerShell connected with Connect-MgGraph (cloud-only users), or on-premises Active Directory (synchronised users)For hundreds of users, Microsoft recommends PowerShell so none are missed. For synchronised users, change the UPN in on-premises Active Directory and let sync update Microsoft 365.
Update-MgUser -UserId annb@contoso.com -UserPrincipalName annb@fabrikam.comYou should see: The user now signs in as annb@fabrikam.com. - 6
Remove the domain from email addresses
Where: PowerShell connected with Connect-ExchangeOnlineUse the EmailAddresses parameter on the cmdlet that matches each RecipientType:
Set-Mailboxfor mailboxes,Set-DistributionGroupfor distribution and mail-enabled security groups,Set-DynamicDistributionGroupfor dynamic groups, andSet-UnifiedGroupfor Microsoft 365 groups. An address that starts with uppercaseSMTP:is the primary; move the primary to another domain before removing the old one.Set-Mailbox -Identity annb@fabrikam.com -EmailAddresses @{add="SMTP:annb@fabrikam.com"} Set-Mailbox -Identity annb@fabrikam.com -EmailAddresses @{remove="smtp:annb@contoso.com"} Set-DistributionGroup -Identity sales@contoso.com -EmailAddresses @{remove="smtp:sales@contoso.com"} Set-UnifiedGroup -Identity marketing -EmailAddresses @{remove="smtp:marketing@contoso.com"}You should see: Rerunning the Get-Recipient command from step 4 returns nothing. - 7
Fix apps that use the domain
Where: Microsoft Entra admin center > App registrations > the app > Expose an API, or Microsoft Graph PowerShellChange or remove any application ID URI that contains the domain. Microsoft says a domain cannot be deleted while any application has an app ID URI that includes it.
You should see: The Get-MgApplication command from step 3 returns nothing. - 8
Remove the domain
Where: Microsoft 365 admin center > Settings > DomainsSelect the domain, then Remove domain in the properties pane, then Remove domain again in the Remove domain? pane. Or run the PowerShell command.
Remove-MgDomain -DomainId contoso.comYou should see: The domain disappears from the Domains list. Microsoft says this can take five minutes when few objects referenced it, or several hours up to a day when many did. - 9
Use ForceDelete only if you accept renaming
Where: Microsoft Entra admin center (Azure portal) > Custom domain names, or Microsoft GraphForceDelete renames remaining user UPNs, email and proxy addresses, group email addresses and app identifier URIs to the onmicrosoft.com domain, and disables the renamed user accounts (optional in Graph). It needs fewer than 1,000 references, no multitenant apps, Exchange-mastered groups cleaned up first, and does not work for federated domains, domains bought through Microsoft 365, or partners acting for a customer.
POST https://graph.microsoft.com/v1.0/domains/contoso.com/forceDelete { "disableUserAccounts": true }You should see: The operation runs in the background. Afterwards a get domain request for contoso.com returns HTTP 404.
Expert tips
Run the reference, user, app and Get-Recipient checks from steps 3 and 4, export them to CSV and work through the list until every command returns nothing. Rerun them right before removal, because new users and groups often get created on the old domain during the project.
For users and groups synced from Active Directory, change the UPN and proxyAddresses in AD and let Entra Connect sync it. Changes made in the cloud are overwritten or rejected for synced objects, and the domain will keep reappearing as referenced.
When moving a domain to another tenant, mail for that domain cannot be delivered to either tenant between removal and verification in the new one. Do all the renaming days ahead, keep the domain itself until the window, then remove it, verify it in the target straight away and add the addresses back there. Microsoft says removal takes about five minutes with few objects and up to a day with many.
ForceDelete renames what is left to onmicrosoft.com and can disable those accounts. It needs fewer than 1,000 references, does not clean up Exchange-mastered groups, and does not work for federated domains or domains bought through Microsoft 365. Clearing references yourself gives you control over each new address.
Sign in as an admin on contoso.onmicrosoft.com. You cannot delete a domain used by your own account name, and the domain cannot be the default, so set another default domain first.
How to confirm it worked
The domain no longer appears on Settings > Domains.
Get-MgDomain -DomainId contoso.comreturns a not found error.The other tenant or service can now add and verify the domain.
How to reverse it
You can add and verify the domain again (see the add-domain how-to), but user names and addresses you moved stay where you put them; change them back by hand. Microsoft warns that if another tenant verifies the domain after you remove it, you cannot add it back to yours. When a domain is removed, any remaining accounts fall back to the onmicrosoft.com address.
Errors you might see
Remove-MsolDomain : Unable to remove this domain. Use Get-MsolUser -DomainName<domain name> to retrieve a list of objects that are blocking removal.Cause: Users or groups still use the domain, proxy addresses for the domain remain on mail-enabled users or groups, or Skype for Business SIP addresses use it.
Fix: Run the Get-MgDomainNameReference and Get-Recipient commands in steps 3 and 4 and clear everything they return.
Domain deletion fails with an error that you have Exchange mastered groups on this domain nameCause: Mail-enabled security groups and distribution lists are provisioned by Exchange and are not cleaned up by ForceDelete.
Fix: Change or remove their addresses in the Exchange admin center or with Set-DistributionGroup, then retry.
Cannot delete the domain while signed in as admin@contoso.comCause: Your own account name references the domain.
Fix: Sign in as an admin on contoso.onmicrosoft.com or another domain.
Delete operation stuck In ProgressCause: It is an asynchronous task that can take up to 24 hours. It fails if apps use the domain in identifier URIs, mail-enabled groups reference it, there are more than 1,000 references, or it is the default domain.
Fix: Wait up to 24 hours, then clean up any remaining references and try again.
ForceDelete fails for a federated domainCause: Microsoft says ForceDelete does not work when the domain uses federated authentication.
Fix: Rename or remove the users and groups in on-premises Active Directory, then retry.
Questions
How long does it take to remove a domain from Microsoft 365?
Microsoft says as little as five minutes when few objects used it, and several hours up to a day when many did. A Delete operation in Entra can take up to 24 hours.
Can I remove the onmicrosoft.com domain?
No. Microsoft says .onmicrosoft.com domains cannot be removed.
Why can't I add the domain to my new tenant?
Microsoft does not allow a domain to be verified in more than one tenant, so it must be fully removed from the old tenant first.
Official sources
Vendors change menus and requirements. Confirm on the source before you rely on a detail. Last checked 4 Nov 2026.