Home Datacenter Get VMware Disk Usage with Powershell

Get VMware Disk Usage with Powershell

by Roger Lund

http://www.peetersonline.nl/index.php has a posted titled Get VMware Disk Usage with Powershell( http://www.peetersonline.nl/index.php/vmware/get-vmware-disk-usage-with-powershell/ )


Using VMware seriously requires a lot of (shared) storage. This kind of storage (on a SAN for instance) is quite expensive. So you might want to check if you are wasting a lot of this space. When you look at the storage in VMware, it consists of multiple abstraction layers. A virtual machine has one or more Logical Disks, which are indicated by driveletters. You can use WMI to determine the amount of used and free space (Win32_LogicalDisk). One or more logical disks are contained in a partition. One or more partitions reside on a physical disk. That physical disk is really a virtual disk, a vmdk file to be precise. One or more vmdk files reside in a Datastore, which can be found on a LUN on your SAN.
The following script enumerates most of these layers (from logical disk to datastore) and calculates the used and free space. The final line exports the results to a csv file for use in Excel. And the script also helps you to calculate the average free space by showing the totals without the duplicates (don’t try to average the averages in excel, that’s not accurate because datastores contain duplicates and averages should be weighed).

This is something I want to try, and I will post results, I am currently trying a Eval of ESX 3.5 U3.

Post your comments if anyone uses this or something like it to monitor disk usage.

Refer to the Full Post to see the code

http://www.peetersonline.nl/index.php/vmware/get-vmware-disk-usage-with-powershell/

You may also like