如何使用 PowerShell 中的 Azure CLI 檢索 Azure VM 的作業系統?
要使用 Azure CLI 檢索 Azure VM 作業系統,我們可以使用 “az vm” 命令,但在使用該命令之前,需要確保你已連線到 Azure 雲和訂閱。
PS C:\> az vm show -n VMName -g VMRG --query "[storageProfile.imageReference.offer]" -otsv
或
PS C:\> az vm show -n VMName -g VMRG --query storageProfile.imageReference.offer - otsv
輸出
WindowsServer
要獲取作業系統 SKU 或作業系統版本,可以使用。
PS C:\> az vm show -n VMName -g VMRG --query "[storageProfile.imageReference.sku]" -otsv
輸出
2016-Datacenter
還可以使用以下命令,在不提供資源組名稱的情況下獲取 VM 的作業系統。
PS C:\> az vm list --query
"[?name==VMName].{os:storageProfile.imageReference.offer}" -otsv要獲取作業系統版本或 SKU,
PS C:\> az vm list --query "[?name==VMName].{os:storageProfile.imageReference.sku}"
-otsv要以表格格式合併所有輸出,
az vm list --query "[].{vmName:name, ResourceGroup:resourceGroup,
os:storageProfile.imageReference.offer, version:storageProfile.imageReference.sku}" -
otable
廣告
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP