Find the Hostname of a Hyper-V VM

If you are running a virtual machine () on , sometimes you want to know on which Hyper-V host this VM is running. If you don't have access to the host, you need to find that information from within the operating system. Luckily, the hostname of the physical Hyper-V server the virtual machine is running on can be found in the registry.

You can find that information under the following registry key:

ComputerHKEY_LOCAL_MACHINESOFTWAREMicrosoftVirtual MachineGuestParameters

You will get some additional information about the host as well as the physical Hyper-V Hostname of the VM.

Find the Hostname of a Hyper-V VM in RegistryFind the Hostname of a Hyper-V VM in Registry

You could also run the following PowerShell command to get the Hyper-V hostname inside the VM:

Get-ItemProperty -Path "HKLM:SOFTWAREMicrosoftVirtual MachineGuestParameters"  | Select-Object HostName

Since we run a version of Hyper-V in our Microsoft Azure datacenters, this also works with Azure VMs.

Get physical hostname of a Hyper-V VM using PowerShell (Azure VM)Get physical hostname of a Hyper-V VM using PowerShell (Azure VM)

I hope this post was helpful and shows you how you can find the hostname the physical Hyper-V host of a VM. if you have any questions feel free to leave a comment below.

And yes, the first screenshot was taken on a Surface Pro X running Hyper-V on Windows 10 on ARM.

 

This article was originally published by Microsoft's Core Infrastructure and Security Blog. You can find the original article here.