Get Windows Azure Active Directory Tenant ID in Windows PowerShell


Summary: Get your Windows Azure Active Directory tenant ID in Windows PowerShell.

Hey, Scripting Guy! Question How can I get my Windows Azure Active Directory tenant ID in Windows PowerShell?

Hey, Scripting Guy! Answer Use the Add-AzureAccount cmdlet to add your Windows Azure account to Windows PowerShell:

PS C:> Add-AzureAccount

          Then use Get-AzureAccount to get the tenant ID:

PS C:>(Get-AzureAccount).ActiveDirectories.ActiveDirectoryTenantID

Comments (6)

  1. Anonymous says:

    Exactly what I needed, thanks!

  2. ChWang (MSFT) says:

    In order to run the Add-AzureAccount and Get-AzureAccount PowerShell cmdlet, you need to install

    Azure Powershell module, not Azure Active Directory Powershell module.

    Thanks
    Chao

  3. Emmanuel ISSALY says:

    It doesnt work, perhaps because i have several tenants?
    i can see a sub and four tenants, but i have trouble getting details on a specific one

  4. Ben says:

    Unfortunately, this won’t work if you’re running a script in a Visual Studio deployment project since it uses an auth token for the account (I wasn’t able to access the Tenant ID for the subscription via "Get-Subscription -Current" either – it was empty).
    This is a bummer since the KeyVault resource manager template requires the TenantId.

  5. ioo says:

    Unfortunately, Get-AzureAccount returns data truncated and the details display nothing 🙁

Skip to main content