Link to home
Create AccountLog in
Avatar of IT Guy
IT GuyFlag for United States of America

asked on

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?
Avatar of IT Guy
IT Guy
Flag of United States of America image

ASKER

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");
 
    }
 
}
ASKER CERTIFIED SOLUTION
Avatar of TomasP
TomasP
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer