Removing domains in Office 365

by [Published on 18 April 2017 / Last Updated on 18 April 2017]

It may appear a simple process and usually it is, however there are some gotchas when removing domains from Office 365, we are going over a couple scenarios related to this process in this article.


 The process to remove a domain may not be that simple, especially when the desired domain had some replication going on which is the case of the scenario that we are working on this article here at

In order to remove a domain in Office 365, logged as administrator in the Office 365 Admin Center, click on Setup and then Domains. A list of all domains added to the subscriptions will be listed, click the desired domain (in our case

A blade with the DNS requirements for the domain will be displayed. In our case, we just want to remove, so click on Remove.


Office 365 is easy to manage and the intelligence behind helps the administrator to accomplish his objectives fast. A good example is when removing a domain, the wizard will not allow a removal if there are any dependencies such as user and other resources (Exchange/Skype for Business) attached to the given domain.

Also, besides of informing that there is a dependency with the domain that we want to remove a list of dependency will be listed and they will be separated in sections as depicted in the image below. By doing that, the wizard points the administrator to the right directon and save lots of time to complete the task. We can save that information and fix those users listed before coming back to remove the domain.


Well, at this point in the game we know for a fact that the domain that we are trying to remove have some dependencies. The easy way is to go to the users in Office 365 and remove them, right? Well, that works if such objects had not been synchronized between on-premises and Office 365.

In order to check, click on Users, then Active Users. Select a user that has (which is the domain that we are planning to remove). In the new blade, click on Delete user, a new blade requiring confirmation will be displayed, click on Delete.


For our surprise the user cannot be deleted because it had been synchronized previously between the on-premises and the Office 365, as informed on the image below.  

If the synchronization is working properly, then the best practice is to remove the user from on-premises and wait for the replication, repeat that step for all accounts and then the domain can be removed.


Removing an Office 365 domain the hard way...

We should cover all scenarios. Let’s assume that this tenant had the synchronization in place, but it was discontinued and we can’t restore the synchronization to its glory.  

A good example happened to me when writing this article (the original idea of this article was to manage Office 365 domains), but I had such a hard time to remove a domain from an old subscription that I used for testing that I decided to focus just on the removal process.

If you are in this situation, the best way is using our old good friend PowerShell to remove the objects, and then return to the Office 365 Admin Console to remove the domain.

The first step is to install the Microsoft Online module in PowerShell, we can do that by using the following command line and hitting Y when requested.

Install-Module MSOnline


The second step, is to import the module that we have just installed using the cmdlet below. To check the load modules, we can use Get-Module cmdlet.

Import-Module MSOnline

After importing the module, we need to connect to the service, we will use the Connect-MSOLService cmdlet and fill out the credentials.


We know for a fact that we had synchronization going between that subscription and our on-premises environment, and we can check if it is still enabled running the following cmdlet.

Get-MSOLCompanyInformation | Select DirectorySynchronizationEnabled


Before starting the process to remove the objects, we need to stop the synchronization configuration. We can do that by running the following cmdlet, and we can repeat the previous cmdlet to check the change on the status of the replication.

Set-MSOLDirSyncEnabled –EnableDirSync $False


When running Get-MSOLUser cmdlet we will have a list of all users of the subscription, we can check that there are some using the domain that we want to remove and some using the default domain which ends with

We want to check all accounts that are using the domain that we are planning to remove, and to do that we can use the following cmdlet.

Get-MSOLUser | Where-Object { $_.UserPrincipalName –like “*” }



We can remove those accounts using Office 365 Admin Center, or PowerShell, an easy way using PowerShell is adding | Remove-MSOLUser to the end of the previous cmdlet and that will start deleting those accounts associated to the domain (a confirmation will be required).


At this point in the game, we don’t have more objects associated to the domain, so we can go back to the Office 365 Admin Center, click on Setup, and then Domains. Click on the domain, and on the new blade, click on Remove.

Now, the experience will be different, the wizard will check and no dependency will be listed because we took care in the previous steps, just click Remove, and the result will be the message bar informing that Domain was successfully removed, click Close.


One last note before we conclude this article, if you are an ITPRO or enthusiast that has several subscriptions and some of them expired, and your domain got stuck in one of them, the best approach to find where your domain is through a simple ticket in Office 365. Just open a ticket and inform them that you want to validate your domain (you must be the owner of such domain for obvious reasons) and you would like to know which subscription that domain is currently associated and they will inform you.

See Also

The Author — Anderson Patricio

Anderson Patricio avatar

Anderson Patricio is a Canadian MVP in Cloud and Datacenter Management, and Office Server and Services, besides of the Microsoft Award he also holds a Solutions Master (MCSM) in Exchange and several other certifications. Anderson contributes to the Microsoft Community with articles, tutorials, blog posts, twitter, forums and book reviews. He is a regular contributor here at,, and Anderson (Portuguese).