The unique identifier of any Microsoft 365 tenant is public information. This means there are no direct security concerns about someone else knowing your tenant’s ID other than that it could be used for social engineering or to interrogate further holes in your security that could then be exploited.
Nevertheless, there are also some legitimate reasons to want to know a tenant’s ID, such as if you need to authenticate to it using any authentication mechanism, if you need to establish a tenant-to-tenant relationship, or even if you are updating documentation.
Let’s look at the methods you can use to find the ID of any Microsoft 365 tenant.
Using PowerShell
The first and my favourite option is to use PowerShell. Below, I have written a small function that queries a public API and returns the ID of any Microsoft 365 tenant.
Function Find-TenantID {
<#
.AUTHOR
Daniel Bradley
ourcloudnetwork.co.uk
.DESCRIPTION
A small PowerShell function to quickly find the tenant ID of any Micorosft tenant using public APIs without authorisation.
.EXAMPLE
Find-TenantID -domain ourcloudnetwork.com
#>
param(
[Parameter(Position=0,mandatory=$true)]
[string] $domain
)
try {
$response = Invoke-RestMethod -UseBasicParsing -Uri "https://odc.officeapps.live.com/odc/v2.1/federationprovider?domain=$domain"
}
Catch {
Return "Unable to run request"
}
#Return
$response.tenantid
} Use the example below and replace the primary tenant domain with your own to get the result.
Find-TenantID -domain ourcloudnetwork.com If you have entered a valid domain, your output should look like the following:
Alternatively, If you want to incorporate this code into your script without the use of a function, you can take the following two lines to get the tenant ID:
$domain = "ourcloudnetwork.com"
Invoke-RestMethod -UseBasicParsing -Uri "https://odc.officeapps.live.com/odc/v2.1/federationprovider?domain=$domain" | Select -expand tenantid Using an online tool
Alternatively, and for ease of use, I have developed a small web app running on Azure App Services using Next.js, which performs the same API call as the above PowerShell script. The tool can be accessed here: entraid.ourcloudnetwork.com
Enter the primary domain name for the target tenant and click Get tenant ID. The tenant ID will be instantly returned to the text box.
Using Conditional Access
The final option is to use the Conditional Access policy creation wizard from inside another (any) tenant to enumerate the tenant ID of any tenant using the primary domain name. Follow the below steps to enumerate a tenant ID using Conditional Access:
2. Expand Protection and select Conditional Access.
3. Select Policies > New policy.
4. Click Users, then under Include, select Users or External Users. Then under Specify external Microsoft Entra organizations, click Select and type in the tenant domain name.
You can then copy and paste the tenant ID as it is displayed in the results area.

