使用 powershell 获取 Azure VM classic 的位置

Get location for Azure VM classic using powershell

使用 powershell 如何使用 powershell 获取 VM classic 的位置。 Get-AzureVM 似乎没有这个信息

我们无法直接从 Get-AzureVM 获取 Azure VM 位置,但我们可以从 VM 获取它 disk.Please 已尝试使用以下代码。

$serviceName = "xxxx"
$vmName ="xxxx"
$vm= Get-AzureVM -ServiceName $serviceName -Name $vmName 
$disk =  Get-AzureDisk -DiskName  $vm.VM.OSVirtualHardDisk.DiskName
$location = $disk.Location