> ## Content Index
> Fetch the complete content index at: https://codeisahighway.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to get the status of an #Azure Virtual Machine under the v2 compute model in #PowerShell v0.9.x
- URL: https://codeisahighway.com/how-to-get-the-status-of-an-azure-virtual-machine-status-under-the-v2-compute-model-in-powershell/
- Published: 2015-05-28T23:37:00.000Z
- Updated: 2026-08-10T07:12:24.000Z
- Author: Stephane Lapointe
- Tags: PowerShell, DevOps, Automation, Microsoft Azure, #Import 2023-07-11 16:44, #Import 2026-09-04 10:31, #Import 2026-09-04 13:56

Since version 0.8.0, the Azure PowerShell can target multiple APIs, included in 2 PowerShell modules. Even if the name of some cmdlets are the same, they greatly differ in their inputs and responses. First we have the older cmdlets, the PowerShell [Azure Service Management Cmdlets](http://go.microsoft.com/fwlink/?LinkID=396348&ref=codeisahighway.com) and then we have the newer APIs [Azure Resource Manage Cmdlets](http://go.microsoft.com/fwlink/?LinkID=394765&ref=codeisahighway.com)

A newer version of this article for Azure PowerShell v1.0.x is available here:  
[How to get the status of a Virtual Machine under the v2 compute model in Azure PowerShell v1.0](https://codeisahighway.com/how-to-get-the-status-of-a-virtual-machine-under-the-v2-compute-model-in-azure-powershell-v1-0)

## Do it, the older cmdlets style

In the older API, to get the VM status you would do the following:

```
Add-AzureAccount -Credential $cred
Select-AzureSubscription -SubscriptionId $mySubscriptionId
$vm = Get-AzureVM -ServiceName 'MyCloudService' -Name 'MyVMName'
$vm | Select-Object Status, PowerState

```

In this example you'll get the state of the VM and cloud service.

Under the newer API (AzureResourceManager), if you call the Get-AzureVM like you would have done in the older API you'll get the deployed definition of the VM but will find no traces of the Virtual machine status.

```
Switch-AzureMode -Name AzureResourceManager
Add-AzureAccount -Credential $cred
Select-AzureSubscription -SubscriptionId $mySubscriptionId
Get-AzureVM -ResourceGroupName "myRG" -Name "MyVMName"

```

> It is important to remember that Virtual Machines in the new model (Compute Resource Provider/v2) do not rely on Cloud Services anymore. In the older model, a virtual machine required a Cloud Service to exist, this is not the case anymore.

There is a link to an excellent article about changes in the new IaaS model in the *Reference* section.

## Do it, the newer cmdlets style

To get the status of the virtual machine under the ARM API, you need to specify a new switch in the PowerShell cmdlet named `-Status`. It will take a little bit more time, but this time you'll have a completely different response than the previous call we made. It will contains the information you are looking for in the `Statuses` member.

```
Switch-AzureMode -Name AzureResourceManager
Add-AzureAccount -Credential $cred
Select-AzureSubscription -SubscriptionId $mySubscriptionId
$vm = Get-AzureVM -ResourceGroupName "myRG" -Name "MyVMName" -Status
$vm.Statuses

```

You will have all the VM information you need to automate your scale up/down and automation scenarios... Enjoy!

### References

- [IaaS Just got easier again](http://azure.microsoft.com/blog/2015/04/29/iaas-just-got-easier-again/?ref=codeisahighway.com)
- [Azure PowerShell Cmdlet Reference](https://msdn.microsoft.com/en-us/library/azure/mt617088.aspx?ref=codeisahighway.com)
- [Azure PowerShell v0.9.8.1 release](https://github.com/Azure/azure-powershell/releases/tag/v0.9.8.1-October2015?ref=codeisahighway.com)