Hyper-V: How to Find the Host of a VM

Hyper-V: How to Find the Host of a VM

There are several ways you can determine the virtualization host (server with the Hyper-V role enabled), also called the physical host, that a VM is running on.

If the host OS is Windows Server 2008 R2, and the virtual machines on it are using the R2 integrations services, then you can query the following:

$[HKLM\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters]

Using SCVMM:

Get-VMMServer cluster.domain.com | Get-VM Server1 | Select-Object vmhost

Replace cluster.domain.com to the FQDN of your VMM cluster and Server1 to the server you're looking for.

Using PowerShell:

This script pulls the host name from the VM's registry.

Function Get-VMHost
    (get-item "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters").GetValue("HostName")

Using WMI and PowerShell

function Get-VMOSDetail
        $ComputerName = $Env:ComputerName,
    # Creating HASH Table for object creation
    $MyObj = @{}
    # Getting VM Object
    $Vm = Get-WmiObject -Namespace root\virtualization -Query "Select * From Msvm_ComputerSystem Where ElementName='$VMName'" -ComputerName $ComputerName
    # Getting VM Details
    $Kvp = Get-WmiObject -Namespace root\virtualization -Query "Associators of {$Vm} Where AssocClass=Msvm_SystemDevice ResultClass=Msvm_KvpExchangeComponent" -ComputerName $ComputerName
    # Converting XML to Object
    foreach($CimXml in $Kvp.GuestIntrinsicExchangeItems)
        $XML = [XML]$CimXml
            foreach ($CimProperty in $XML.SelectNodes("/INSTANCE/PROPERTY"))
                switch -exact ($CimProperty.Name)
                    "Data"      { $Value = $CimProperty.VALUE }
                    "Name"      { $Name  = $CimProperty.VALUE }
    # Outputting Object
    New-Object -TypeName PSCustomObject -Property $MyObj

Using System Center Configuration Manager:

This T-SQL query can be used to generate a report giving the number of hosts per guest:

SELECT [PhysicalHostNameFullyQualifi0] AS [Host FQDN], COUNT(PhysicalHostNameFullyQualifi0) AS [Count of Guests]
  GROUP BY [PhysicalHostNameFullyQualifi0]
This T-SQL query can used to generate a report matching hosts to guests 

SELECT sys.Netbios_Name0, vm.PhysicalHostName0, vm.ResourceID
JOIN v_R_System AS sys ON vm.ResourceID = sys.ResourceID

Using MMC:


See Also

Sort by: Published Date | Most Recent | Most Useful
  • hi, this is good info. however, is there any way for me to check the "history" host owner of one particular virtual machine?  

  • Raymond: Please clarify - are you looking for the "owner" of a virtual machine, regardless of the host it is currently on, or may have been on in the past?


    Are you looking for a list of all the hosts a particular VM has been on?

  • AFAIK there is no way to track "host history" of a VM *on* or "from" the VM. If you have the required credentials and access to the *host* log files, you should be able to parse and track who/what regarding any VM on the host.

  • hi tonyso, thanks for ur feedbac.   i m looking for the history (past) host where my desire VM located....  looks there is no other way besides checking from cluster.log ...

    Hi tonysoper, mind to share the step?

  • Raymond, If I understand correctly what you are trying to do, there is no way to do that in Hyper-V. I am not positive, but I don't think there is a way in SCVMM either. You should check with the SCVMM community just to be sure, try social.technet.microsoft.com/.../virtualmachinemanager

  • The PowerShell above can be replaced with a one-liner:

    (get-item "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters").GetValue("HostName")

  • It's really great!

  • thanks for sharing, helpful post

  • nice article

  • How to get host of a VM if its a linux machine ?