Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
View the status of ARM VMs using PowerShell.
December 9, 2015
Q. How can I view the status of my ARM VMs using PowerShell?
A. To view the status of an Azure RM VM using PowerShell you must add the -Status parameter which includes an array of statuses, one of which is the current powerstate., e.g.
Get-AzureRmVM -ResourceGroupName "SAVILLTECHRGEASTUS" -Name "testvm44" -Status
To view the status for all VMs you could use something like the following:
$RGs = Get-AzureRMResourceGroupforeach($RG in $RGs){ $VMs = Get-AzureRmVM -ResourceGroupName $RG.ResourceGroupName foreach($VM in $VMs) { $VMDetail = Get-AzureRmVM -ResourceGroupName $RG.ResourceGroupName -Name $VM.Name -Status foreach ($VMStatus in $VMDetail.Statuses) { if($VMStatus.Code.CompareTo("PowerState/deallocated") -eq 0) { $VMStatusDetail = $VMStatus.DisplayStatus } } write-output $VM.Name $VMStatusDetail }}
Basically in the above PowerShell I go through all resource groups for all VMs and for each find the status related to power state then output.
You May Also Like