Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Azure VM Detail by PowerShell

I am trying to run Get-AzureVM PowerShell command, it is running fine but not return any output.

Also tried in following flavor but still blank result any idea?

Get-AzureVM -Name "vmname" |Select-Object name,instancesize,location
like image 351
Vinay Rajput Avatar asked Dec 11 '13 13:12

Vinay Rajput


2 Answers

You should call Select-AzureSubscription "subscription name" first.

It likely is defaulting to a subscription that doesn't have any virtual machines in it.

To view your current subscription names call:

Get-AzureSubscription | select SubscriptionName
like image 65
Michael Washam Avatar answered Sep 25 '22 17:09

Michael Washam


Actually the answer above is only semi-correct.

This had me pulling my virutal hair out trying to do automation (which took 7 hours of manual fudging to get working!).

Simply, you have two types of virtual machine in Azure; Classic, and Resource Manager.

If you Switch-AzureMode -name AzureServiceManagement then use Get-AzureVM you will list all of the classic VM's you have created.

If you Switch-AzureMode -name AzureResourceManager then use Get-AzureVM you will list all of the Resource Manager (or new) VM's you have created.

And remember, if you are trying to do automation, then you need the VM's in the new mode available through the portal, your old VM's (classic) that you created through management are not visable in this mode and you will have to recreate them.

like image 31
Glyn Avatar answered Sep 21 '22 17:09

Glyn