Find the Hostname of a Hyper-V VM

Published Jan 19 2021 05:12 AM 7,442 Views
Microsoft

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 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:\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 (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.

2 Comments
Senior Member

Very useful feature :) Works also on Azure Stack Hub :)

Microsoft

@cblackuk oh yes true, can be very handy on Azure Stack Hub machines as well!

%3CLINGO-SUB%20id%3D%22lingo-sub-2074171%22%20slang%3D%22en-US%22%3EFind%20the%20Hostname%20of%20a%20Hyper-V%20VM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2074171%22%20slang%3D%22en-US%22%3E%3CP%3E%3C!--%20wp%3Aparagraph%20--%3E%3C%2FP%3E%0A%3CP%3EIf%20you%20are%20running%20a%20virtual%20machine%20(VM)%20on%20Hyper-V%2C%20sometimes%20you%20want%20to%20know%20on%20which%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fvirtualization%2Fhyper-v-on-windows%2Fabout%3FWT.mc_id%3Dmodinfra-11833-thmaure%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EHyper-V%3C%2FA%3E%20host%20this%20VM%20is%20running.%20If%20you%20don't%20have%20access%20to%20the%20Hyper-V%20host%2C%20you%20need%20to%20find%20that%20information%20from%20within%20the%20virtual%20machines%20operating%20system.%20Luckily%2C%20the%20hostname%20of%20the%20physical%20%3CA%20href%3D%22https%3A%2F%2Fwww.thomasmaurer.ch%2F2019%2F07%2Fhow-to-install-hyper-v-server-2019%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EHyper-V%3C%2FA%3E%20server%20the%20virtual%20machine%20is%20running%20on%20can%20be%20found%20in%20the%20virtual%20machines%20registry.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3C!--%20%2Fwp%3Aparagraph%20--%3E%20%3C!--%20wp%3Aparagraph%20--%3E%3C%2FP%3E%0A%3CP%3EYou%20can%20find%20that%20information%20under%20the%20following%20registry%20key%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3C!--%20%2Fwp%3Aparagraph%20--%3E%20%3C!--%20wp%3Apreformatted%20--%3E%3C%2FP%3E%0A%3CPRE%20class%3D%22wp-block-preformatted%22%3EComputer%5CHKEY_LOCAL_MACHINE%5CSOFTWARE%5CMicrosoft%5CVirtual%20Machine%5CGuest%5CParameters%3C%2FPRE%3E%0A%3CP%3E%3C!--%20%2Fwp%3Apreformatted%20--%3E%20%3C!--%20wp%3Aparagraph%20--%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20will%20get%20some%20additional%20information%20about%20the%20Hyper-V%20host%20as%20well%20as%20the%20physical%20Hyper-V%20Hostname%20of%20the%20VM.%3C!--%20wp%3Aimage%20%7B%22id%22%3A19751%2C%22sizeSlug%22%3A%22large%22%2C%22linkDestination%22%3A%22none%22%7D%20--%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Find-the-Hostname-of-a-Hyper-V-VM-scaled.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F247426i5C176B03510DBD80%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Find-the-Hostname-of-a-Hyper-V-VM-scaled.jpg%22%20alt%3D%22Find%20the%20Hostname%20of%20a%20Hyper-V%20VM%20in%20Registry%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EFind%20the%20Hostname%20of%20a%20Hyper-V%20VM%20in%20Registry%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EYou%20could%20also%20run%20the%20following%20PowerShell%20command%20to%20get%20the%20Hyper-V%20hostname%20inside%20the%20VM%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3C!--%20%2Fwp%3Aparagraph%20--%3E%20%3C!--%20wp%3Apreformatted%20--%3E%3C%2FP%3E%0A%3CPRE%20class%3D%22wp-block-preformatted%22%3EGet-ItemProperty%20-Path%20%22HKLM%3A%5CSOFTWARE%5CMicrosoft%5CVirtual%20Machine%5CGuest%5CParameters%22%20%20%7C%20Select-Object%20HostName%3C%2FPRE%3E%0A%3CP%3E%3C!--%20%2Fwp%3Apreformatted%20--%3E%20%3C!--%20wp%3Aparagraph%20--%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESince%20we%20run%20a%20version%20of%20Hyper-V%20in%20our%20Microsoft%20Azure%20datacenters%2C%20this%20also%20works%20with%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fvirtual-machines%3FWT.mc_id%3D%3FWT.mc_id%3Dmodinfra-11833-thmaure%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20VMs%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%3C!--%20%2Fwp%3Aparagraph%20--%3E%20%3C!--%20wp%3Aimage%20%7B%22id%22%3A19756%2C%22sizeSlug%22%3A%22large%22%2C%22linkDestination%22%3A%22none%22%7D%20--%3E%3C%2FP%3E%0A%3CP%3E%3C!--%20%2Fwp%3Aimage%20--%3E%20%3C!--%20wp%3Aparagraph%20--%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Get-physical-hostname-of-a-Hyper-V-VM-using-PowerShell.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F247427i4A3E016C79995217%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Get-physical-hostname-of-a-Hyper-V-VM-using-PowerShell.jpg%22%20alt%3D%22Get%20physical%20hostname%20of%20a%20Hyper-V%20VM%20using%20PowerShell%20(Azure%20VM)%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EGet%20physical%20hostname%20of%20a%20Hyper-V%20VM%20using%20PowerShell%20(Azure%20VM)%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EI%20hope%20this%20post%20was%20helpful%20and%20shows%20you%20how%20you%20can%20find%20the%20hostname%20the%20physical%20Hyper-V%20host%20of%20a%20VM.%20if%20you%20have%20any%20questions%20feel%20free%20to%20leave%20a%20comment%20below.%3C%2FP%3E%0A%3CP%3E%3C!--%20%2Fwp%3Aparagraph%20--%3E%20%3C!--%20wp%3Aparagraph%20--%3E%3C%2FP%3E%0A%3CP%3EAnd%20yes%2C%20the%20first%20screenshot%20was%20taken%20on%20a%20%3CA%20href%3D%22https%3A%2F%2Fwww.thomasmaurer.ch%2F2020%2F06%2Frun-hyper-v-on-windows-10-on-arm-and-the-surface-pro-x%2F%22%20target%3D%22_blank%22%20rel%3D%22noreferrer%20noopener%20nofollow%22%3ESurface%20Pro%20X%20running%20Hyper-V%20on%20Windows%2010%20on%20ARM%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%3C!--%20%2Fwp%3Aparagraph%20--%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2074171%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Find-the-Hostname-of-a-Hyper-V-VM-scaled.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F247428iB8DF6A5CF26E96B4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Find-the-Hostname-of-a-Hyper-V-VM-scaled.jpg%22%20alt%3D%22Find-the-Hostname-of-a-Hyper-V-VM-scaled.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EIf%20you%20are%20running%20a%20virtual%20machine%20(VM)%20on%20Hyper-V%2C%20sometimes%20you%20want%20to%20know%20on%20which%20Hyper-V%20host%20this%20VM%20is%20running.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2074171%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EThomas%20Maurer%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2074196%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20the%20Hostname%20of%20a%20Hyper-V%20VM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2074196%22%20slang%3D%22en-US%22%3E%3CP%3EVery%20useful%20feature%20%3A)%3C%2Fimg%3E%20Works%20also%20on%20Azure%20Stack%20Hub%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2074198%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20the%20Hostname%20of%20a%20Hyper-V%20VM%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2074198%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F292415%22%20target%3D%22_blank%22%3E%40cblackuk%3C%2FA%3E%26nbsp%3Boh%20yes%20true%2C%20can%20be%20very%20handy%20on%20Azure%20Stack%20Hub%20machines%20as%20well!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Version history
Last update:
‎Jan 19 2021 05:12 AM
Updated by: