Detecting HyperV host and guest machines using WMI/CIM/WS

Given an IP address of a server, I would like to identify using WMI/WBEM calls whether the server is
1) An HyperV host
2) An HyperV gues
3) Other

Are there specific API calls/classes that can clearly reveal the above information ?
LVL 1
pspexpertAsked:
Who is Participating?
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.

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
pspexpertAuthor Commented:
Thanks for the info Shahid, while it's helpful doesn't actually answer my question.

To elaborate further if I were to issue a WMI call to an IP address, what are the classes I need to look at to programatically identify if a server is an HyperV "Host" machine.
0
pspexpertAuthor Commented:
Ooops, please read "doesn't actually answer my question" as "doesn't actually answer my question completely".

thanks
0
msmamjiCommented:
Dim WMIService
Dim VMHost
VMHost = ".“

‘ Connect to the CIMOM in the destination machine
‘ we use the \virtualization namespace.
Set WMIService = GetObject( "winmgmts:\\" & VMHost _
                        & "\root\Virtualization")
‘ Connect to WMI class that represents VSMS
Set VMService = WMIService.Get("Msvm_VirtualSystemManagementService")
0
msmamjiCommented:
Sorry posted to quickly
The above code was copied from
http://download.microsoft.com/download/5/b/9/5b97017b-e28a-4bae-ba48-174cf47d23cd/VIR043_WH06.ppt
If a server is hyper-V host you can connect to it using the \root\virtualization namespace

test it and it work.
Maybe that might help.
Regards,
Shahid
Dim WMIService
Dim VMHost
VMHost = "."

' Connect to the CIMOM in the destination machine
' we use the \virtualization namespace.
Set WMIService = GetObject( "winmgmts:\\" & VMHost _
                        & "\root\Virtualization")
' Connect to WMI class that represents VSMS
Set VMService = WMIService.Get("Msvm_VirtualSystemManagementService")

Open in new window

0
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
Microsoft Virtual Server

From novice to tech pro — start learning today.