-- Ben Armstrong, Virtualization Program Manager
Talking about core virtualization at Microsoft (Hyper-V, Virtual PC and Virtual Server).
So I have been spelunking through the Virtual Server WMI interfaces, and found this handy one for reporting the amount of physical hard disk space used by each virtual machine.
Option Explicit Dim strComputer, objWMIService, colVMs, vm, totalDisk totalDisk = 0strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\vm\virtualserver") Set colVMs = objWMIService.ExecQuery("SELECT * FROM VirtualMachine",,48) For Each vm in colVMs Wscript.Echo "-----------------------------------" Wscript.Echo vm.name & ":: Disk space used: " & _ vm.DiskSpaceUsed / 1048576 & _ " MB (" & vm.DiskSpaceUsed & " bytes)" totalDisk = totalDisk + vm.DiskSpaceUsedNext Wscript.Echo "-----------------------------------" Wscript.Echo "All virtual machines" Wscript.Echo "-----------------------------------" Wscript.Echo "Disk space used: " & totalDisk / 1048576 _ & " MB (" & totalDisk & " bytes)"
Option Explicit
Dim strComputer, objWMIService, colVMs, vm, totalDisk
totalDisk = 0strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\vm\virtualserver") Set colVMs = objWMIService.ExecQuery("SELECT * FROM VirtualMachine",,48) For Each vm in colVMs Wscript.Echo "-----------------------------------" Wscript.Echo vm.name & ":: Disk space used: " & _ vm.DiskSpaceUsed / 1048576 & _ " MB (" & vm.DiskSpaceUsed & " bytes)" totalDisk = totalDisk + vm.DiskSpaceUsedNext
Wscript.Echo "-----------------------------------" Wscript.Echo "All virtual machines" Wscript.Echo "-----------------------------------" Wscript.Echo "Disk space used: " & totalDisk / 1048576 _ & " MB (" & totalDisk & " bytes)"
The nice thing is that it gives you the total disk usage, even when the virtual machine has multiple virtual hard disks attached. The not so nice thing is that it only reports this information for virtual machines that are currently running.
Cheers,Ben
I barely know what you're saying, I know just enough about the computer's inards to keep me out of trouble (same with software).
What PHYSICAL disk space is required for the Virtual PC and Windows XP?
I've asked this question several time, but haven't had a straight anwer yet.
HELP!
scooter@scootersdesk.com