I was recently given the task of identifying the state of an Azure VM so that an automation script using the
az vm run-command invokewould not fail if the VM was down or under a reboot.
I initially thought the task would be really easy and a simple query of the VM state using
Get-AzVMwould provide us with a running state property of the VM, but as it happens the state is a little abstracted.
Click through to see how Mark solved the challenge.