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

Check out Where To Find Tenant ID In Azure Portal

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.

You may also like following the articles below

Azure Virtual Machine

DOWNLOAD FREE AZURE VIRTUAL MACHINE PDF

Download our free 25+ page Azure Virtual Machine guide and master cloud deployment today!