Find the Hostname of a Hyper-V VM

Find the Hostname of a Hyper-V VM

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

You can find that information under the following registry key:

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters

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

Find the Hostname of a Hyper-V VM in Registry
Find 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:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters"  | 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
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.

4 responses

  1. Balaji Avatar

    How to enable internet on Hypwr V. Srarched in Google and ms docs not useful.

    1. I have created vm in Azure
    2. Installed Hyper v role in the vm
    3. In Hyper V console I have created NEW VM
    4. Here in the new VM internet not working

    I have ckecked added network card, enabled EXTERNAL for internet

    BBUT STILL internet not working

    Can you please help me in this

    1. Thomas Maurer Avatar

      Simple, just follow these steps. The issue is that you cannot just create an external switch, you will need to create a NAT switch, you can find all of that here: https://www.thomasmaurer.ch/2017/07/how-to-setup-nested-virtualization-in-microsoft-azure/

  2. Stephane IT Avatar
    Stephane IT

    Hello Thomas,
    Thanks for the info and your blog!
    Any chance you can point me to a ressource for doing the opposite of your post ?
    I want to guess the hostname of the VM (Linux or dos VMs) from the host’s PowerShell.

    We have a lot of Hyper-V hosts and I move the VMs quite often. I’d be nice to have the VMname AND the VM hostname (fqdn ideally), any chance you have a ressuorce to point to ?
    thanks for sharing ✌

  3. mikha Avatar

    how can you get the replication server name from the virtual machine?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.