Find Your Hyper-V VM’s Host Name with PowerShell

Find Your Hyper-V VM’s Host Name with PowerShell

Use PowerShell to find your Hyper-V host host name from inside a VM

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:

HKLM\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters

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")

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish