Introduction

In order to use your domain with Office 365, you will first need to verify your domain name and setup the DNS records that Microsoft provides. The best way I have found to do this is through the Office 365 cmdlets in PowerShell. These cmdlets are not installed out of the box so you will need to install them first.

Installing the Office 365 cmdlets

You must be running at least Windows Server 2008 /Windows 7 and have at least Net Framework 3.5.1.

To install:

Azure Active Directory Module for Windows PowerShell (32-bit version)

Azure Active Directory Module for Windows PowerShell (64-bit version)

Connecting to Office 365 instance with PowerShell

Once you have ensured you have installed the Office 365 cmdlets start PowerShell (Making sure you run as administrator) and type the following command:

Import-Module MSOnline

You have now imported Microsoft Online Services cmdlets.
Next you need to connect to Office 365 using your administrator credentials. Run the following command:

Connect-MsolService

Adding and Verifying a Domain

To add a domain run the following command:

New-MsolDomain -Name testdomain.co.uk

To check this has been added correctly you can get a list of domains associated with Office 365 by running:

Get-MsolDomain

You should see something similar to this:

Get-MsolDomain

Obviously I do not own the domain testdomain.co.uk but this shows the reason the verification process is important. Without it I would be able to verify any domain name.
Microsoft provides two methods to verify domains both in the form of adding DNS entries. You can either add a TXT or MX record. A TXT record is recommend as this is unlikely to not affect your domain if miss configured.

To get your verification code run the command:

Get-MsolDomainVerificationDns -DomainName testdomain.co.uk -Mode DnsTxtRecord

You should see something similar to this:

testdomain

You will need to add this record to your DNS zone file, I have included an example below of what it should look like when using cPanel however most providers will be similar.

Add a record

Once the record has been added you will need to wait for this to propagate. This can take anywhere from minutes to 48 hours depending on your DNS provider.
Once the record has propagated you need complete the verification by running the following:

Confirm-MsolDomain -DomainName testdomain.co.uk

When Office 365 finds the required TXXT/MX record your domain is verified. You can run Get-MsolDomain cmdlet again to check.

Your domain is now ready to start setting up Microsoft services with such as Exchange and SharePoint.

Share