如何在 PowerShell 中使用 Azure CLI 获取当前登录的用户帐户?

powershellmicrosoft technologiessoftware & coding更新于 2026/2/12 16:37:17

要使用 Azure CLI 获取已连接的用户帐户,您需要使用以下命令。

PS C:\> az account show

输入该命令后,您将获得如下所示的 JSON 格式的输出。

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"
   }
}

要获取表格格式的输出,请使用 -otable 或 –output table

PS C:\> az account show -otable

相关文章