Querying guest operating system information with Powershell

I recently posted how to query guest operating system information using VBScript.  It was pointed out to me that this was much easier to do using Powershell, so here is a sample script that will do the same thing with Powershell:

$vs=new-object –com VirtualServer.Application –Strict
$result = SetSecurity($vs)
$vm = $vs.FindVirtualMachine(“Windows Server”)
$result = SetSecurity($vm)
$guestOS = $vm.GuestOS
$result = setSecurity($guestOS)

Of course in order for this to work you need to have your Powershell environment setup as detailed in this post and this post.

When run this will provide output that looks like:

IsHostTimeSyncEnabled : True
HeartbeatPercentage   : 100
IsHeartbeating        : True
OSName                : Windows ServerT 2003, Enterprise Edition Service Pack 1
AdditionsVersion      : 13.709
CanShutdown           : True

As it will list all of the properties of the object and their current values.