Retrieving the status of a VM is rather straightforward. To retrieve the state of a specific virtual machine, use the Get-AzureRmVM command, taking care to specify valid names for the VM and the resource group.
Run the following command to check the status of the myVM virtual machine:
Get-AzureRmVM `
-ResourceGroupName "VMLab" `
-Name "myVM" `
-Status
The command in the preceding example retrieves the current status of the myVM virtual machine. While the output will include quite a bit of information, what we are most concerned about for this exercise is the part that shows whether the VM is running:
The resulting output indicates the current status of the VM.