One of my customers has bought another company, so they needed to add the new company domain to their environment. This company has a hybrid exchange organization and I had to do some simple steps.

As a first step I recommend you to start the PowerShell documentation as I have described in one of my previous article “10 Useful PowerShell cmdlets for Exchange

Start-Transcript

Now we have documentation about all steps we have done for these tasks.

Now we need to connect to the right tenant, where we want to add our new domain. To do that, we need this command:

Connect-MsolService

After entering our credentials, we will be redirected to our tenant. Now we can check the status of our existing domains, which are assigned to our tenant, for that we run:

Get-MsolDomain

Here we see now the Names, Status and Authentication settings of our existing domain.

To add another domain to this tenant, we can run the following command:

New-MsolDomain –Name “contoso.com”

Simple, right? However, we are not finished yet. A new domain always needs to be verified, and to do that we will use the public DNS. That means we need a TXT-Record which we need to create in the public DNS zone of the domain, we want to add to our tenant. That we are able to do that and that we know what we have entry we have to create in the public DNS, we run this command:

Get- MsolDomainVerificationDns –DomainName contoso.com –Mode DnsTxTRecord

With this information we switch to our public DNS and create the TXT-record.

After we have created the record, we need to wait a bit. DNS needs a bit of time till the replication is done. To improve the changes that Microsoft gets the new record, we go back to our PowerShell console and hit the following command to verify, if the new DNS entry is already ready:

nslookup -type=TXT contoso.com 8.8.8.8

If the result looks good for us, and we get the positive reply, we need to do one final step on the tenant shell. We need to confirm the new Domain. This we do with the following command:

Confirm-MsolDomain -DomainName contoso.com

As we can see in the output of this command, everything went well.

To be sure how it looks now, we can run again one of our first commands to see if the new domain looks how it should do:

Get-MsolDomain

And if we like what we see, we just have to stop our documentation with:

Stop-Transcript

Now we are done.

 

The next task I want to show you here is what I had to do on the Exchange site.

We have now registered the new domain to our tenant, now we also need to present the new domain to the Exchange environment. To do that I have written a mini script which I was running on the Exchange management shell on the on-premises Exchange:

#region Create accepted domains on the on-premise server
Write-Host 'Creating the accepted domains for Contoso and Fabrikam' -ForegroundColor cyan
New-AcceptedDomain -Name 'contoso.com' -DomainName contoso.com -DomainType Authoritative
New-AcceptedDomain -Name ' fabrikam.net ' -DomainName fabrikam.net -DomainType Authoritative
#set brake for replication
sleep -seconds 12
Write-Host 'Accepted Domains sucessfully created!' -ForegroundColor green
#endregion

That the users, which were working in the bought company are still available on their old mail addresses, we need to add the old address to their new mailboxes, they have got in the new company. I will not post now the whole script I was running for that. However, I will post one example how doing that by PowerShell:

Set-RemoteMailbox -Identity "Desmond.Miles" -EmailAddresses @{add="[email protected]"}

Now we have one last thing to do. We need to modify the MX-Records of the Domain Contoso.com. When we have changed them, the mail flow will go to the right destination.

This is all for the moment, I hope this article was a little help for you…