Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Verify Azure AD Tenant Availability

January 24, 2024
in Azure Active Directory, Blog, Entra ID, Powershell
0
ADVERTISEMENT

Table of Contents

Before you subscribe for a new Microsoft 365 tenant, you will have to choose a name for your tenant. The name will be used in the links for several applications, such as SharePoint Online.

Check Microsoft 365 Tenant Name is Available

There are several ways to achieve this goal. 

The first way, we can use the following online services to do a quick check for the availability of a tenant name in Microsoft 365.

  • http://o365.rocks/
  • https://www.m365namecheck.com/
  • https://www.easy365manager.com/tenant-availability-checker/
  • https://accessorange.com/microsoft-365-tenant-name-availability-check/

Below is an example when the domain duybao3.onmicrosoft.com can use to create a new Microsoft 365 tenant. And the domain duybao2.onmicrosoft.com is already taken.

8HmzET0Y07mnXSIFfAMjru6qz0OQoVBLkz9XCCUPnDxGjYxdCQUTT4Nzu4BX

Using a web browser

The second way, we can check the availability of the new domain you want. For example, if you want the domain name duybao3.onmicrosoft.com.com, let’s enter https://login.microsoftonline.com/duybao3.onmicrosoft.com/FederationMetadata/2007-06/FederationMetadata.xml in a browser.

If you get a message that the tenant couldn’t be found (404), it’s probably available. So, we can use the domain name to create a new Microsoft 365 tenant.

vV4ZjoCZusb7wXzzdu74dNXXa7sRjJ50qEAuFec8y9aYgZ23MsisSVgFBNAr

When you browse to an existing Azure AD tenant, you will get the XML data and an HTTP status code 200. Then the domain has already been taken and you’ll need to try a different one.

5LAEobZVsVUTf3wFyk6aWxJlK4GYgUcB2VxE5dooxNYvOUugvULAuceOXTrt

Verify Azure AD Tenant availability using PowerShell

The third way, I used a very inconspicuous trick to check the tenant availability, and too much of my surprise, it still works, to this day. I used to check for the presence of a particular XML file, one that should be present in all Azure Active Directory tenants, even your own! 

The Microsoft identity platform uses the SAML 2.0 protocol to enable applications to supply a single sign-on experience to their users and we can use that to our advantage. Here is what the docs say about the subject.

The tenant-specific endpoint is located at: https://login.microsoftonline.com/<TenantDomainName>/FederationMetadata/2007-06/FederationMetadata.xml.

The <TenantDomainName> placeholder represents a registered domain name or TenantID GUID of an Azure AD tenant. For example, the federation metadata of the contoso.com tenant is at https://login.microsoftonline.com/contoso.com/FederationMetadata/2007-06/FederationMetadata.xml

When you browse to an existing Azure AD tenant, you will get the XML data and an HTTP status code 200.

  • Try it for contoso.com

When you browse to an Azure AD tenant that should not exist, you won’t get the XML data and an HTTP status code 404.

  • Try it for abc.def.com

Now, we can go ahead to wrap this up into anything we want, a PowerShell script will be enough for our automation purposes. Here’s a little sample we cooked up, which you can also view on GitHub:

You can copy the below code snippets, change the domain name as you need, and then paste them into a PowerShell window at once or create a PowerShell script to run it locally later.

$domain = 'duybao8.onmicrosoft.com'
$login = 'https://login.microsoftonline.com/'
$fed = '/FederationMetadata/2007-06/FederationMetadata.xml'
$uri = $login + $domain + $fed

if ($PSVersionTable.PSVersion.Major -eq 5) {
    $response = try { 
        (Invoke-WebRequest -Uri $uri -Method GET -ErrorAction Stop).BaseResponse
    } catch [System.Net.WebException] { 
        $_.Exception.Response
    }
    $StatusCode = $response.StatusCode.Value__
}

if ($PSVersionTable.PSVersion.Major -ge 7) {
    $response = Invoke-WebRequest -Uri $uri -Method GET -SkipHttpErrorCheck
    $StatusCode = $response.StatusCode
}

switch ($StatusCode) {
    200 {
        Write-Host "The tenant's name $domain is unavailable." -ForegroundColor Red
    }
    404 {
        Write-Host "The tenant's name $domain is available." -ForegroundColor Green
    }
}

For example, we’ve created a PowerShell script named domain.ps1. When running the script, we just need to enter the domain name, the script does the rest.

sM7X3eY9i81DLUrjHUTbZeAF0sZbah82tJWdkY5Kmh6HfHXXC5bho2kwxzhK

Additionally, if you don’t want to create a PowerShell script manually. All you need to do is executive the single-line PowerShell script directly:

irm https://bonguides.com/ps/tenantcheck | iex
TdDr4H6ukjXyo5VdXa43kTjwAkhV5hwCa4IQ4IwUv72Etzfd7EIKR7pE3KL9

Using Microsoft Partner Center

The last way, if you have access to Partner Center, you can install the Partner Center PowerShell module to verify Azure AD tenant availability.

Install-Module -Name PartnerCenter -AllowClobber -Scope CurrentUser
Connect-PartnerCenter
Test-PartnerDomainAvailability -Domain 'contoso.onmicrosoft.com'
# Output
Account                                  Environment      TenantId
-------                                  -----------      --------
e3d3decc-ee3c-xxxx-8f80-99d59771672e     AzureCloud       615dc844-xxxx-40c2-9db4-0439991ec82e

PS C:\> Test-PartnerDomainAvailability -Domain 'contoso.onmicrosoft.com'
False
PS C:\> Test-PartnerDomainAvailability -Domain 'duybao3.onmicrosoft.com'
True

Conclusion

Regardless of which possibility suits you best, I hope this has been insightful!

ADVERTISEMENT

Not a reader? Watch this related video tutorial:

5/5 - (1 vote)
Previous Post

How to Create an Unlimited Client Secret in Microsoft Entra ID

Next Post

Your Instance was not Created Because a Security Group with Same Name Already Exists in Azure Active Directory

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory