Some friends here on the Hyper-V team shared a PowerShell 2.0 script for checking in the hypervisor is running on a Hyper-V server (host/parent partition):
# Check if Hypervisor is running
$hypervisor = gwmi –ErrorAction SilentlyContinue Win32_PerfRawData_HvStats_HyperVHypervisor
return $hypervisor.Partitions -ge 1
For more info on how to use PS cmdlets see: http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/index.mspx
See also James O’Neil’s New and improved PowerShell Library for Hyper-V. Now with more functions and… documentation!
For all 35 sample Hyper-V PS1 scripts in a zipfile, go to: Hyper-V PowerShell Example Scripts.zip-download