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]
"HostName"=
"PhysicalHostName"="
"PhysicalHostNameFullyQualified"=
"VirtualMachineName"=

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
{
    Param(
        [Parameter()]
        $ComputerName = $Env:ComputerName,
         
        [Parameter()]
        $VMName
         
    )
     
    # 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
 
        if($XML)
        {
            foreach ($CimProperty in $XML.SelectNodes("/INSTANCE/PROPERTY"))
            {
                switch -exact ($CimProperty.Name)
                {
                    "Data"      { $Value = $CimProperty.VALUE }
                    "Name"      { $Name  = $CimProperty.VALUE }
                }
            }
            $MyObj.add($Name,$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]
  FROM [v_GS_VIRTUAL_MACHINE]
  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
FROM dbo.v_GS_VIRTUAL_MACHINE AS vm
JOIN v_R_System AS sys ON vm.ResourceID = sys.ResourceID

Using MMC:

Resources:






See Also