如何使用 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