Let's face it, you are designing an application or writing a script against your virtual server host machine and need to pull out some important information about the host server or its virtual machines but you don't know how to go about getting it. Happens all the time and to the best of us. Good thing we have people like Ben Armstrong to keep us all in the know. Ben comes through again with a great way to programmatically grab a virtual machine's uptime information from Virtual Server.
Virtual Server 2005 R2 provides a set of statistical information about its virtual machines through the VMAccountant object. Ben provides a simple script that will go through all virtual machines on a physical server and display how long the VMs have been running as reported by the accountant object. NOTE, the values are reported in seconds.
Set vs = CreateObject("VirtualServer.Application")
set vms = vs.VirtualMachines
For Each vm in vms
Wscript.Echo "Virtual machine: " & vm.Name
Wscript.Echo "Uptime: " & vm.Accountant.Uptime
Wscript.Echo
Next
Read Ben's original post on his site,
here, and feel free to thank him or comment on his solution.