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

Information Protection for Office 365 Poster Microsoft Office 365 team released a new update of the Information Protection poster for Office 365. Here are some of the updates: Enterprise Mobilit...
Free busy failure from on-premises to Office 365 m... After completing an Exchange Hybrid Configuration wizard on a customer, we noticed that the free-busy information wasn’t working when an on-premises u...
Managing Federation Services– Enabling Single Sign... Configuring an existent domain in Microsoft Azure to support Single Sign-On (SSO) Solution At this point in the game we have already installed, con...
Office365 Admin Preview A brief sight seeing in the Office 365 Admin Preview, the admin center preview was informed by the Office365 team back in 2015 and it is being rolled ...