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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IT GuyNetwork EngineerAuthor Commented:
I have looked at this URL:

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

Function Get-VMHost
    $HKLM = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine", $ComputerName);
    $key = $HKLM.OpenSubKey("SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters");
    if ($key -eq $null)
        return $null;
        return $key.GetValue("HostName");
I believe that your best bet is to use the WMI classes to retrieve/information

Just to get the host server name it can be found in the guest registry
"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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2008

From novice to tech pro — start learning today.