Reputation: 786
i wish to get the location of the VM for classic machines from powershell. I tried all the methods from Get-AzureVM
, but couldn't get the location.
I am able to get locations of the VM's from Get-AzureRmVm
(ARM)
Upvotes: 1
Views: 1434
Reputation: 786
Another approach to get the location of an ASM model Virtual machine is to use the location of the service of the respective VM's
We can get the location of the service by using Get-AzureService | select-object Location
Upvotes: 1
Reputation: 19195
You could not directly use Get-AzureVM
to get VM location. You could use get-AzureVM | Get-Member
to check. There is no location
in the result.
For classic VMs, you could get VM location by using the following cmdlet.
$vm=Get-AzureVM -ServiceName shui -Name shui
$uri=$vm.VM.OSVirtualHardDisk.MediaLink.AbsoluteUri
Get-AzureDisk | Where-Object {$_.MediaLink -eq $uri}| Select-Object Location
This is my result.
Upvotes: 2
Reputation: 805
Firstly you should call Get-AzureSubscription
and select your subscription name:
Get-AzureSubscription | Select SubscriptionName
Confirm it's correct and not the default:
Get-AzureSubscription -Current
Then you can run the following:
Get-AzureVM -Name "VM Name" | Select-Object name,instancesize,location
Further information can be found here
Upvotes: -1