VMware Cloud Community
tsm1979
Contributor
Contributor

Getting the Used Space of a VMDK's for VM's not in the inventory

I can successfully search a datastore for all .vmdk files using the following:


dir vmstore:\ha-datacenter\MyDatastore\ -Recurse -Include *.vmdk

This returns the vmdk file size in bytes and the conversion is straightforward once I dump the results out to CSV.

What it doesn't tell me is the used space of that VMDK.  This is something I can obtain by using Get-VM VMName | Select UsedSpaceGB.  However, in order to do this, the VM obviously needs to be added to the inventory.

I have several hundred VMDK's spread across multiple datastores that are not in the inventory.

Is there a method I could use to obtain the following:

  • Search all datastores for .VMDK files
  • Display the used space of the VMDK
  • Display the LastWriteTime of the VMDK
  • Display the full folder path of the VMDK.
  • Dump it all out into a CSV

If I use the vSphere client, I can browse the datastore and the data I need is there, it is displayed as 'Size' and 'ProvisionedSize', however doing this for several hundred files would probably take me weeks and is not practical :smileyblush:

Any help would be appreciated Smiley Happy

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

Some of these points are answered in my Orphaned files and folders – Spring cleaning post.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos