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

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 ...
Adding an endpoint on Office 365 Exchange data mig... There is an easy assistant under Setup / Data migration when using Office 365 Admin Center. In this Tutorial, we are going over the process to configu...
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...
How to activate synchronization in Office365 We are going over the process to enable synchronization in the new Office 365 Administration Center and also using PowerShell.  Solution In s...