Use Microsoft Graph
Install-Module Microsoft.graph
Connect-MgGraph -Scopes "User.ReadWrite.All","Domain.ReadWrite.All"
![](https://www.azure365pro.com/wp-content/uploads/2023/03/image.png)
Importing Bulk Domains to CSV
Import-Csv .\Export.csv | ForEach-Object {New-MgDomain -BodyParameter @{Id=$_.domainname}}
![](https://www.azure365pro.com/wp-content/uploads/2023/03/image-1.png)
To get verification code for each domain
Get-MgDomain |ForEach-Object {(Get-MgDomainVerificationDnsRecord -DomainId $_.id | Where-Object {$_.RecordType -eq "Txt"}).AdditionalProperties.text}
![](https://www.azure365pro.com/wp-content/uploads/2023/03/image-2-1024x546.png)
run get-mgdomain put in a sheet, run this and put in the next column. Saves a lot of time.
What headers does the CSV need to have?