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 MSExchange.org) 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.

Solution


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.

image

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.

Connect-MSOLService

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

image

To remove the domain ITPROCentral.com 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 ITPROCentral.com

image

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 ITPROCentral.com, MSExchange.org, Techgenix.com and Anderson Patricio.org (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...
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...
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 ...
Quarantine messages in Exchange Online Protection ... In this Tutorial we are going to check the required steps for an end-user to check its quarantine messages in EOP.  In some customers, I see the ...