VMware Cloud Community
Astaroth420
Contributor
Contributor
Jump to solution

Obtaining Virtual Hard Disk Used Space with PowerCLI

Hello,

I'm trying to build a Powershell script in which I need to obtain, for each thin-provisioned hard disk in a given VM, how much space is currently used.

The catch is that I'm trying to obtain only the data that is currently written on the disk, which excludes the space being taken by parents or anything of the sort. I'm strictly looking for the total size of the files that are written on the disk. Unfortunately, the HardDisk object, according to the vSphere PowerCLI reference, has no member or extension data related to the used space on the disk, only what is currently provisioned.

There is a way to obtain the value I'm looking for through the vSphere Client (see screenshot http://puu.sh/8EsXn.png), but I'm trying to obtain that same value through a Powershell script instead.

Any help would be greatly appreciated.

EDIT: To clarify the attached screenshot, the field "Taille" is what I'm looking for, as "Taille allouée" is a synonym of Provisioned Space.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I suspect that is a Thin Provisioned disk you are showing in the screenshot ?

Have a look at my yadr – A vdisk reporter post.


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

I suspect that is a Thin Provisioned disk you are showing in the screenshot ?

Have a look at my yadr – A vdisk reporter post.


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

0 Kudos
Astaroth420
Contributor
Contributor
Jump to solution

Thanks for the reply!

I did take a look at your script earlier this morning, and I've managed to run it. Unfortunately, the metrics outputted by your script don't seem to match what I'm looking for. (What is being shown by my vSphere Client)

From what I understand from your script, it takes into account the size of all the snapshots related to each virtual machine in it's calculations. However, I'm getting the impression that I'm not supposed to take these into account. I might be wrong though.

So my follow-up question is this: would there be a way to calculate the space being used on each virtual disk without taking into account the snapshots?

Thanks again.

0 Kudos