如何在 Powershell 中使用 Azure CLI 來獲取當前登入的使用者帳戶?


要獲取連線的使用者帳戶和 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

更新日期: 01-Sep-2021

10K+ 瀏覽

開啟你的 職業生涯

完成課程以獲得認證

開始
廣告