Removing a domain in Office 365 using PowerShell

Share this:

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.

Written by Anderson Patricio

Anderson Patricio

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

Related Post

Product Review: Exclaimer Cloud – Signatures... Exclaimer is well-known within the Microsoft world with regards to its email signature management solutions and I have installed several of its produc...
How to enable RMS in Office365 The process to enable RMS in Office 365 is simple and it can be done in just a few minutes.SolutionThe entire process is performed using PowerShell, t...
Where is my Office 365 data? A common question that I receive from my customers is about where is my data in Office 365 and the second if I can have my users spread all over the p...
Configuring Directory Synchronization in Office 36... How to start the synchronization between on-premises and Office 365 using the Office365 Admin Center Preview. In this Tutorial, we are going to run th...