Q: I remotely manage a number of different VMs that are running on multiple Hyper-V hosts and I don’t always know the Hyper-V host name of the VM that I’m using. Is there a way I can find the Hyper-V host name from inside the VM?
A: You can find the Hyper-V host name in the guest VM’s registry at the following key:
However, repeatedly looking into the registry with regedit can be time consuming and tedious. The following PowerShell command retrieves the VM’s host name and it works on Windows Server 2008 and higher.
PS C:\temp> (get-item "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters").GetValue("HostName")