View status of ARM VMs using PowerShell

View the status of ARM VMs using PowerShell.

John Savill

December 9, 2015

1 Min Read
ITPro Today logo in a gray background | ITPro Today

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.

About the Author

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.

You May Also Like