Gathering disk usage information via WMI

  • Comments 1

Continuing on our saga through the undocumented Virtual Server WMI interfaces, we now arrive at disk usage information.  Here is a sample script that will create a list of the currently running virtual machines, and display the amount of disk activity they have had since they were powered on.

Set vsWMIObj = GetObject("winmgmts:\\.\root\vm\virtualserver")
Set vms = vsWMIObj.ExecQuery("SELECT * FROM VirtualMachine",,48)
For Each vm in vms
    Wscript.Echo "=============================================="
    Wscript.Echo "Virtual machine: " & vm.Name
    Wscript.Echo "MiB read from disk: " & vm.DiskBytesRead / 1048576
    Wscript.Echo "MiB written to disk: " & vm.DiskBytesWritten / 1048576

As you can see these disk counters usually report values in bytes.  It is important to note that these counters are also reset to zero every time the virtual machine is turned off.


Leave a Comment
  • Please add 5 and 7 and type the answer here:
  • Post
  • This is nice, are there more WMI interfaces when you can determine the virtual machine installed on a server and if they are running or not? What about where all the virtual disk location are stored locally? Etc.

    What I’m trying to do is to create a VBS that will document your VS setup. I have created ones for SMS and for MOM and I created one for VS using all the WMI names spaces that I already know about however that does not provide a lot of info so I have not released the beta version of this script yet.

    Anyways, I you would like to know more about this VBS or can provide more information so that I can update the VBS. Please feel free to contact me directly.  

Page 1 of 1 (1 items)

Gathering disk usage information via WMI