In OSB projects, customers that have to purchase a new tenant for starting their Office 365 journey always run into issues of the tenant name and if the defined name are available or not.

Microsoft offers the way to check the tenant name on the Tenant creation wizard but sometimes will be better to check it in a more direct way.

That’s why we created a PowerShell script easy to run that can help on this.

The script is the following:

 param( $Name )
 $uri = "https://portal.office.com/Signup/CheckDomainAvailability.ajax"
 $body = "p0=" + $name + "&assembly=BOX.Admin.UI%2C+Version%3D16.0.0.0%2C+Culture%3Dneutral%2C+PublicKeyToken%3Dnull&class=Microsoft.Online.BOX.Signup.UI.SignupServerCalls"
 $response = Invoke-RestMethod -Method Post -Uri $uri -Body $body
 $valid = $response.Contains("SessionValid")
 if ($valid -eq $false)
 {
 Write-Host -ForegroundColor Red $response
 Exit
 }
 $available = $response.Contains("<![CDATA[1]]>")
 if ($available)
 {
 Write-Host -ForegroundColor Green "Available"
 }
 else
 {
 Write-Host -ForegroundColor Yellow "Taken"
 }
 

To use the script just save it as GetNewTenantName.ps1 in a folder and run it from a PS Shell on any PC connected to internet.

Get-TenantStatus.ps1 -name “name to test”

the result will be like the follow:

 

Comments are closed.