Removing a domain in Office 365 using PowerShell

Removing a domain in Office365/EOP requires that all accounts that are associated to that domain to be transferred to a valid domain, and the administrator must check several details. I wrote an article for Techgenix (former with all the steps that must be validated, you can check it out using this link here, however the focus was to remove the domain using the Office 365 Admin center where all validations are made before removing the domain.


In Today’s Tutorial, we are going to use a lumberjack approach where we are not going to perform all the validation to rearrange the objects to a new domain but instead we are going to remove the domain. Keep in mind that is the last resource, and we always should try to use the method on the Techgenix article.

For starters, we are trying to remove first using the Office 365 Admin Center, and as expected the error message informing that there are users using that domain will be displayed.


We can remove the domain without validation using PowerShell, first let’s connect on the Office 365 Service by opening Microsoft Azure Active Directory Module for Windows PowerShell, and after that we will connect on the service executing the following cmdlet. An authentication window will be displayed, enter your information to connect to Office365.


After that we will list the domains available on the tenant.


To remove the domain we should use the following cmdlet, and confirm when prompted. Afterwards, let’s list the domains again to make sure that the domain was removed properly.

Remove-MSOLDomain –DomainName


The process to remove a domain using PowerShell is simple and powerful, however it should be done as last resource and in a controlled environment.