Get Currently Logged-in User Account with Azure CLI in PowerShell



To get the connected user account with the Azure CLI, you need to use the below command.

PS C:\> az account show

Once you type the command, you will get the output in JSON format as shown below.

PS C:\> az account show
{
   "environmentName": "AzureCloud",
   "homeTenantId": "Your tenant ID",
   "id": "Subscriptio ID",
   "isDefault": true,
   "managedByTenants": [],
   "name": "Subscription Name",
   "state": "Enabled",
   "tenantId": "tenant ID",
   "user": {
    "name": "user logged in email id or username",
    "type": "user"
   }
}

To get the output in the table format, use the -otable or –output table

PS C:\> az account show -otable
Updated on: 2021-09-01T09:35:09+05:30

11K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements