Remove Domain from Office 365 Tenant using Powershell

If you ever tried the services of Office 365, it comes up with 30 days trial and starts de-provisioning the services after some time. You always have an option to pay as you go to Microsoft to continue that tenant. However, if you want to test or use it for one another month, you have to remove from exiting expired Tenant, create a new O365 Tenant, and finally add into it to continue using Office 365 services.

Let me walk you through the easy steps using Powershell to remove your domain from the expired tenant:

a) Open Powershell or ISE in Administrator Mode and connect to Msol Service:

$credential = Get-Credential  
Import-Module MsOnline
Connect-MsolService -Credential $credential

Note: Enter the Global Admin Credentials of Office 365 expired tenant in the popup.

b) If you have any data in any of your mailboxes, take the backup of the mailbox in .pst by first configuring it into Outlook. (in case there is no data, you can directly move to the next step).

c) Run the following commands in Powershell or ISE:

Get-Msoluser | Remove-MsolUser -force

Get-MsolUser -ReturnDeletedUsers | Remove-Msoluser -RemoveFromRecycleBin -force

Do check for any existing groups using and if any delete them using the below command.

Get-MsolGroup -all | Remove-MsolGroup -force

Note: Before removing your domain, make sure your domain name should not be used with any user’s email address, alias, groups, public folders, etc. Finally, go ahead and remove your domain:

Get-MsolUser -domainname | Remove-Msoluser -force

Note: It may take few minutes to remove the domain from the existing tenant.

d) Create a new Office 365 Tenant and add into it, re-publish its DNS records in the DNS Service Provider. Once verified, the status of will become healthy.

e) Create Users with and check the external mail-flow (Gmail to your new tenant).

Enjoy your new Office 365 Tenant with all services for another 30 days.

If you face any issue while adding into new Office 365 Tenant using the GUI mode, you may also try the below PowerShell method:

Add Domain using Powershell to new Office 365 Tenant:

a) Connect to Office 365 Powershell with the new tenant’s [email protected] Global Admin (its the first Global Admin while creating a new tenant):

$credential = Get-Credential  
Import-Module MsOnline
Connect-MsolService -Credential $credential

b) Run the below Powershell Commands to add your domain to newly created Office 365 Tenant:

New-MsolDomain -Name

$txtrecord+=(Get-MsolDomainVerificationDNS -DomainName -mode dnstxtrecord)

$txtrecord | select-object Text,Label,TTL | Export-csv c:\TxtRecord.csv

Note: You will get a TxtRecord.csv file in your C:\ Drive. Copy the values from there and add it to your DNS Service Provider.

c) Come to Office 365 Admin Center (Left Pane) – Setup – Domains – Select – Check DNS – Microsoft will verify that you own and will provide you 3 final records to start using Office 365 Services: Mx, Txt, Cname Records need to be added finally to your DNS Service provider.

d) Once all 3 records are published, click Verify and the Status of will become healthy.

e) Create users with email address and check Mail-Flow externally (from Gmail to

Thanks a ton for reading my above blog. If you have any comments, suggestions, or feedbacks please spare a second to post it.

Must check:

a) Create Skillshare Premium Account.

b) Create Lynda Premium Account.

c) Create LinkedIn Learning Premium Account for free.

d) Create Pluralsight Premium Account. 

Subscribe Us

Total Page Visits: 6183 - Today Page Visits: 4

Add a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.