Retrieve vmId of Virtual Machine
Sometimes retrieving the unique ID of a virtual machine in Resource Manager can be usefull. The following snippet will grab the vmid property.
1 2 3 |
$vm = Get-AzureRmVM -ResourceGroupName 'rg' -Name 'vm' $vmResource = Get-AzureRmResource -ResourceName $vm.Name -ResourceGroupName $vm.ResourceGroupName -ResourceType 'Microsoft.Compute/virtualMachines' $vmId = $vmResource.Properties.VmId |