When preparing clients for moving to Office 365 you often run across a scenario where they have many domains to add and verify in the tenant. The process for verifying ownership can be long and annoying for lots of domains if you are getting the detail manually, however, the following two PowerShell commands can help save you time!
Firstly, create a CSV with all of your domains, and add them to the tenant with the following command (where there is one column in your CSV called DomainName:
Import-CSV <Path to your CSV File> | Foreach{New-MsolDomain -Name $_.DomainName}
This will add all of your required domains to the tenant. You can then retrieve all of the required TXT records to validate ownership with the following command:
Get-MsolDomain -Status unverified | Foreach{Get-MsolDomainVerificationDns -DomainName $_.Name -Mode DNSTxtRecord}
And finally, once you have added these DNS records for your domains you can validate them using the following command:
Get-MsolDomain -Status unverified | Foreach{Confirm-MsolDomain -DomainName $_.Name}
So long as the DNS record has been added and propagated you should have all of your domains verified in the tenant!
If you have any questions or comments please either use the comments section below, Tweet me @MikeParker365 or via email blog@mikeparker365.co.uk.