VMware Cloud Community
TheVMinator
Expert
Expert
Jump to solution

Accessing "Used Storage" field via PowerCLI

Can I use PowerCLI to total the "provioned storage" field for all vmdks on a vm, then total the "Used storage" field visible in vsphere client, then find out how much total space is provisioned vs how much is used for a VM?

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can store the VM in a variable, and then do your calculations directly on the properties

$vm = Get-VM -Name MyVM
$vm.ProvisionedSpaceGB - $vm.UsedSpaceGB


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

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

I'm afraid the used storage for a VM is monitored by datastore, not per VMDK.

The totals are directly available

Get-VM |
Select Name,ProvisionedSpaceGB,UsedSpaceGB


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

TheVMinator
Expert
Expert
Jump to solution

OK great thanks.  How would I format output so that those values, provisionedspaceGB and UsedSpaceGB are stored in variables that I can do math on in my next line?  (When I use "select", it puts it in table format)


0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can store the VM in a variable, and then do your calculations directly on the properties

$vm = Get-VM -Name MyVM
$vm.ProvisionedSpaceGB - $vm.UsedSpaceGB


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

0 Kudos
TheVMinator
Expert
Expert
Jump to solution

OK great thanks

0 Kudos