When you are working on the VM remotely, Sometimes, you need to know on which Hyper-V server your VM currently hosted. It could be wasting a time if you have too many Hyper-V server or Hyper-V Cluster.
In this article, I will show you how to find the Hyper-V server name from the inside of the VM guest.
Basically, the information of the Hyper-V hostname is stored on the Windows Registry on the following path:
We will use Get-Item CmdLet to get the information faster. Below is the complete command to get the information.
Get-Item "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters"
As you can see in the image above, there are some values on the registry. Now we need to get only the HostName Value. Below the command to do that.
(get-item "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters").GetValue("HostName")