VMware Cloud Community
jpoling
Enthusiast
Enthusiast

Datastore Provisioned space

Is there a way with powershell to grab the provisioned space for a datastore? I would like to have a quick script that lists the datastore capacity, providioned space, and free space.

I know I can get freespace and capacity (get-datastore <datastore> | select FreeSpaceMB, CapacityMB), but I am not sure about the provisioned space.

Thanks for any insight.

jeff

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

Did you already have a go at the scripts in and

____________

Blog: LucD notes

Twitter: lucd22


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

Reply
0 Kudos
nkange
VMware Employee
VMware Employee

You can actually do that in a simple way...

To calculate the provisioned space value that is displayed in the summary for a datastore do this:

$ds = Get-Datastore | Get-View

$ds | Select -ExpandProperty Summary | Select Name, Capacity, FreeSpace, @{N="Provisioned"; E={ ($_.Capacity - $_.FreeSpace + $_.Uncommitted) }}

Make sure that you refresh storage information before doing this, you could trigger that by doing

$ds | % { $_.RefreshDatastoreStorageInfo() }

Hope that helps

Reply
0 Kudos
admin
Immortal
Immortal

That is pretty handy.. but how do I output the $ds objects to csv?

I tried adding

C:\Program Files\VMware\Infrastructure\vSphere PowerCLI> $ds | select -Expandproperty Summa

ry | select Name, Capacity, FreeSpace, @{N="Provisioned";E={($_.Capacity - $_.FreeSpace + $_.Uncommited) }} |

*export-csv "c:\temp\mw-datastore.csv -notypeinformation

--never mind .. figured it out.

| export-csv c:\temp\mwdata.csv -notypeinformation

BUT I don't think this shows the total amount of space allocated provisioned per vm added together on the datastore.

What can you use to determine this information

Used

Allocated

Capacity

like this chart:

or this chart (capacity section of the datastore summary tab that shows total provisioned space — the maximum potential growth of all virtual machines if thin provisioned disks were fully utilized)

Reply
0 Kudos