How to get tenant id in Azure using PowerShell

In this Azure PowerShell article, we will discuss how to get tenant ID in Azure using PowerShell, Azure CLI, and Azure Portal.

How to get tenant ID in Azure using PowerShell

Finding tenant ID in Azure using PowerShell using the below Azure PowerShell cmdlet is pretty simple.

 Connect-AzAccount
Get-AzTenant

After executing the Azure PowerShell cmdlet, I got the below expected output.

PS C:\WINDOWS\system32>  Connect-AzAccount
Get-AzTenant

Account                   SubscriptionName         TenantId                           
-------                   ----------------         --------                           
fewlines4biju@hotmail.com Visual Studio Enterprise xxxxxxxx-0310-xxxx-xxxb-xxxxxxxx...

Id                    : xxxxxxxx-0310-xxxd-xxxb-xxxxxxxxxxxx
TenantId              : xxxxxxxx-0310-xxxd-xxxb-xxxxxxxxxxxx
ExtendedProperties    : {[Directory, hotmail.com], [DisplayName, Default Directory], 
                        [TenantCategory, Home], [TenantType, AAD]...}
TenantCategory        : Home
Country               : 
CountryCode           : IN
Name                  : Default Directory
Domains               : {fewlines4bijuhotmail.onmicrosoft.com}
DefaultDomain         : fewlines4bijuhotmail.onmicrosoft.com
TenantType            : AAD
TenantBrandingLogoUrl : 

The screenshot below shows that I have executed the above command and got the expected output as the tenant’s details.

az cli get tenant id

How to get tenant ID in Azure using Azure CLI

You can also find the tenant ID using Azure CLI by executing the cmdlet below.

az login
az account list
az account tenant list

After executing the above Azure CLI cmdlet, I got the below output.

{
    "cloudName": "AzureCloud",
    "homeTenantId": "xxxxxxxx-0310-xxxd-xxxb-xxxxxxxxxxxx",
    "id": "1gh4300-dee5-4518-5c5c-feaa72a6ghj1",
    "isDefault": true,
    "managedByTenants": [],
    "name": "Visual Studio Enterprise",
    "state": "Enabled",
    "tenantId": "xxxxxxxx-0310-xxxd-xxxb-xxxxxxxxxxxx",
    "user": {
      "name": "fewlines4biju@hotmail.com",
      "type": "user"
    }

You can see it here

azure cli get tenant id

How to find tenant ID in Azure Portal

In addition to using Azure PowerShell and Azure CLI, you can quickly get the tenant ID in Azure Portal by following the instructions below.

  1. Log in to Azure Portal.
  2. Search for Azure Active Directory and then click on the search result Azure Active Directory.
get tenant name from tenant id powershell

3. On the Azure Active Directory window, Scroll a bit down and click on the properties link from the left navigation. You can able to view the tenant ID under the Tenant properties as shown below.

how to get tenant id in azure using powershell

You may also like following the articles below

Final Words

In this article, we discussed how to find tenant ID in Azure using PowerShell, Azure CLI, and Azure Portal. Now it’s your turn to decide which method best suits you.