Gathering virtual machine uptime information from Virtual Server

Virtual Server 2005 R2 provides an interesting set of statistical information about virtual machines through the VMAccountant object.  Below is a simple script that will go through all virtual machines on a physical computer and display the information about how long they have been running as reported by their accountant objects:

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

Note that the uptime information is reported in seconds.