How can I determine what the host server is for a Hyper V guest server operating system?

How can I determine what the host server is for a Hyper V guest server operating system?

I have connected using remote desktop to the Hyper V guest operating system, which is Server 2008 R2.

I need to get the server name of the server that hosts this Hyper V guest operating system.

Is there a way that I can look this information up from within the Hyper V guest operating system or by looking in Active Directory Users and Computers?
IT GuyNetwork EngineerAsked:
Who is Participating?
 
TomasPCommented:
I believe that your best bet is to use the WMI classes to retrieve/information
http://msdn.microsoft.com/en-us/library/cc136990(v=VS.85).aspx

Just to get the host server name it can be found in the guest registry
From http://www.mekong.net/tech/identify_server_host.htm
"It turns out that a Microsoft Virtual Server actually stores the name of the physical host in the virtual machine's registry. This means that we can determine the physical host from a command session within the virtual machine. It also means that we can display that information using BGInfo.

The physical host is stored in the registry at this location:

 HKLM\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters\PhysicalHostNameFullyQualified
0
 
IT GuyNetwork EngineerAuthor Commented:
I have looked at this URL:
http://social.technet.microsoft.com/wiki/contents/articles/hyper-v-how-to-find-the-host-of-a-vm.aspx

For the power shell script that it mentions, what file extension should this script be saved with?

Function Get-VMHost
 
{
 
    Param([string]$ComputerName=$env:COMPUTERNAME)
 
    $HKLM = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine", $ComputerName);
 
    $key = $HKLM.OpenSubKey("SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters");
 
    if ($key -eq $null)
 
    {
 
        return $null;
 
    }
 
    else
 
    {
 
        return $key.GetValue("HostName");
 
    }
 
}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.