Add Office 365 Domain using PowerShell

0
562
views

Add Office 365 Domain using PowerShell

In this post, I will look at how to add a new Office 365 Domain using PowerShell.

Before we start with adding the domain we need to make sure that we have the following information available.

  1. Tenant ID
  2. FQDN of the new Domain you want to add
  3. The FQDN must be registered with a DNS registrar
  4. You need to know how to add a TXT record to the Registered DNS zone with the registrar

To get started, we need to establish a connection to Microsoft Office 365. This can be done using the following script posted on TechNet. https://gallery.technet.microsoft.com/office/Connect-To-Office-365-9b235018

Or use the following method

Once you have provided your login details run the following cmdlet to establish the connection.

Once the connection has been established, let’s verify the current Domains in the Tenant by running the following cmdlet.

Before we can go ahead and add the new domain we need to find out what the Office 365 tenant ID is, this can be found running the following cmdlet.

Now that you have the Tenant ID, let’s go ahead and create create the new domain using the following cmdlets.

New Domain has been added successfully

As we can see the status of the domain is still as Unverified, so our next step is to complete the verification process.

The following cmdlet will return the DNS TXT record details which needs to be added to your domain DNS records.

We need to use the following details from the output.

  • Label
  • Txt
  • Tlt

This is what the TXT record will then look as follow.

Now that the new record has been created with the Domain hosting provider, let’s go ahead and verification that the new TXT record has been created.

Now that we have our record created and verified, let’s go ahead and complete the domain verification process.

The verification process can be completed by running the following cmdlet.

Let’s go ahead and run the following cmdlet again to view all verified domains in the tenant.

As we can see the newly added domain has been added and verified as well.

To sum it up, in this post we have covered how to add a new domain to Office 365 using PowerShell.

#ThatLazyAdmin

Sharing is caring!

LEAVE A REPLY

Please enter your comment!
Please enter your name here