Microsoft Azure – 使用 Azure PowerShell 检查 Azure VM 的状态
以下 Azure PowerShell 命令可帮助您查找 Azure VM 配置和 Os Name、Os Version、Hyper V Generation、Disks 属性、Type Handler Version、Status 和 Message 的 Extensions 属性、Type Handler Version、Status 的 VM Agents 属性的详细信息和消息以及 VM 电源状态代码、消息、插件、生成时间等。
Azure PowerShell 命令:
Get-AzVM -Name "vm_name" -ResourceGroup "resource_group_name" -status
例子:
Get-AzVM -Name "CloudOpsVM" -ResourceGroup "Cloud-Operations" -status
它返回 Azure VM 的完整深入状态的属性。这些属性包括资源组名称、VM 计算机名称、VM 主机名称、操作系统名称、操作系统版本、Hyper V 生成、VM 磁盘属性、VM 扩展属性等。
Note: To get the Azure VM properties VM should be in the running state,
示例 1:当 VM 处于运行状态时,状态如下所示(请参阅示例输出数据和示例输出图像)。
样本输出数据:
ResourceGroupName : Cloud-Operations
Name : CloudOpsVM
ComputerName : CloudOpsVM
OsName : Windows Server 2019 Datacenter
OsVersion : 10.0.17763.2183
HyperVGeneration : V2
BootDiagnostics :
Disks[0] :
Name : CloudOpsVM_OsDisk_1_xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Statuses[0] :
Code : ProvisioningState/succeeded
Level : Info
DisplayStatus : Provisioning succeeded
Time : 1/3/2022 6:21:20 PM
Extensions[0] :
Name : AzureNetworkWatcherExtension
Type : Microsoft.Azure.NetworkWatcher.NetworkWatcherAgentWindows
TypeHandlerVersion : 1.4.2059.1
Statuses[0] :
Code : ProvisioningState/succeeded
Level : Info
DisplayStatus : Provisioning succeeded
Message : Default configuration is in effect.
Extensions[1] :
Name : DependencyAgentWindows
Type : Microsoft.Azure.Monitoring.DependencyAgent.DependencyAgentWindows
TypeHandlerVersion : 9.10.12.18430
Statuses[0] :
Code : ProvisioningState/succeeded
Level : Info
DisplayStatus : Provisioning succeeded
Message : Plugin enabled (handler name: Microsoft.Azure.Monitoring.DependencyAgent.DependencyAgentWindows, extension name: , version: 9.10.12.18430).
Extensions[2] :
Name : MicrosoftMonitoringAgent
Type : Microsoft.EnterpriseCloud.Monitoring.MicrosoftMonitoringAgent
TypeHandlerVersion : 1.0.18064.0
Statuses[0] :
Code : ProvisioningState/succeeded
Level : Info
DisplayStatus : Provisioning succeeded
Message : Latest configuration has been applied to the Microsoft Monitoring Agent.
VMAgent :
VmAgentVersion : 2.7.41491.1032
ExtensionHandlers[0] :
Type : Microsoft.Azure.AzureDefenderForServers.MDE.Windows
TypeHandlerVersion : 1.0.3.1
Status :
Code : ProvisioningState/succeeded
Level : Info
DisplayStatus : Ready
Message : Plugin enabled (handler name: Microsoft.Azure.AzureDefenderForServers.MDE.Windows, extension name: , version: 1.0.3.1).
ExtensionHandlers[1] :
Type : Microsoft.Azure.Monitoring.DependencyAgent.DependencyAgentWindows
TypeHandlerVersion : 9.10.12.18430
Status :
Code : ProvisioningState/succeeded
Level : Info
DisplayStatus : Ready
Message : Plugin enabled (handler name: Microsoft.Azure.Monitoring.DependencyAgent.DependencyAgentWindows, extension name: , version: 9.10.12.18430).
ExtensionHandlers[2] :
Type : Microsoft.Azure.NetworkWatcher.NetworkWatcherAgentWindows
TypeHandlerVersion : 1.4.2059.1
Status :
Code : ProvisioningState/succeeded
Level : Info
DisplayStatus : Ready
ExtensionHandlers[3] :
Type : Microsoft.Azure.RecoveryServices.VMSnapshot
TypeHandlerVersion : 1.0.71.0
Status :
Code : ProvisioningState/succeeded
Level : Info
DisplayStatus : Ready
ExtensionHandlers[4] :
Type : Microsoft.EnterpriseCloud.Monitoring.MicrosoftMonitoringAgent
TypeHandlerVersion : 1.0.18064.0
Status :
Code : ProvisioningState/succeeded
Level : Info
DisplayStatus : Ready
Message : This virtual machine has successfully connected to Azure Log Analytics.
Statuses[0] :
Code : ProvisioningState/succeeded
Level : Info
DisplayStatus : Ready
Message : GuestAgent is running and processing the extensions.
Time : 1/3/2022 6:24:34 PM
Statuses[0] :
Code : ProvisioningState/succeeded
Level : Info
DisplayStatus : Provisioning succeeded
Time : 1/3/2022 6:23:12 PM
Statuses[1] :
Code : PowerState/running
Level : Info
DisplayStatus : VM running
示例输出图像:
示例 2:当 Azure VM 处于 Deallocated 状态时,状态如下所示(请参阅示例输出)。
样本输出: