VMware Cloud Community
DevKhurana
Enthusiast
Enthusiast
Jump to solution

Get total Storage Detail of ESXi via powercli

Hi , Could anyone help in getting total storage capacity and used storage capacity via powercli script. It is showing in below screen shot highlighted in yellow. 

 

DevKhurana_0-1612311313909.png

 

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try something like this

$report = Get-VMHost -Name MyEsx -PipelineVariable esx | Get-Datastore |
Select @{N='VMHost';E={$esx.Name}},Name,FreeSpaceMB,CapacityMB

$report += '' | Select @{N='VMHost';E={'Total'}},@{N='Name';E={''}},
    @{N='FreeSpaceMB';E={($report | Measure-Object -Property FreeSpaceMb -Sum).Sum}},
    @{N='CapacityMB';E={($report | Measure-Object -Property CapacityMB -Sum).Sum}}

$report


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

View solution in original post

0 Kudos
10 Replies
LucD
Leadership
Leadership
Jump to solution

Did you actually search this community?
That same question has been posted before.


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

0 Kudos
DevKhurana
Enthusiast
Enthusiast
Jump to solution

I searched but didn't find anything helping. 

0 Kudos
scott28tt
VMware Employee
VMware Employee
Jump to solution

@DevKhurana 

This was on the search results for "storage capacity": https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Storage-usage-for-a-particular-data-st...

 


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
0 Kudos
DevKhurana
Enthusiast
Enthusiast
Jump to solution

Thanks but this does fulfil my requirement, but I searched more and found this below, this is actually nearby my requirement but can we put a filter of a single esxi host and get all connected storage capacity, used and free details. 

 

DevKhurana_0-1612369125399.png

 

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You could do something like this

Get-VMHost -Name MyESx -PipelineVariable esx | Get-Datastore |
Select @{N='VMHost';E={$esx.Name}},Name,FreeSpaceMB,CapacityMB


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

0 Kudos
DevKhurana
Enthusiast
Enthusiast
Jump to solution

Thanks LucD, You almost brought me at solution. Can you help me out also to get subtotal of all FreeSpaceGB and CapacityGB in this script

 

Get-VMHost -Name myesx01 -PipelineVariable esx01 | Get-Datastore |
Select @{N='VMHost';E={$esx01.Name}},Name,
FreeSpaceGB,
CapacityGB

0 Kudos
LucD
Leadership
Leadership
Jump to solution

What do you mean by subtotal?


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

0 Kudos
DevKhurana
Enthusiast
Enthusiast
Jump to solution

Means, It shows many datastores connected to a esx and their sizes,  I want a total also of that many datastores FreeSpaceGB and CapacityGB something like below if possible

 FreeSpaceGBCapacityGB
 152566
 41111
 52150
 62200
 5423000
 52510
 2550
   
Total9264587
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try something like this

$report = Get-VMHost -Name MyEsx -PipelineVariable esx | Get-Datastore |
Select @{N='VMHost';E={$esx.Name}},Name,FreeSpaceMB,CapacityMB

$report += '' | Select @{N='VMHost';E={'Total'}},@{N='Name';E={''}},
    @{N='FreeSpaceMB';E={($report | Measure-Object -Property FreeSpaceMb -Sum).Sum}},
    @{N='CapacityMB';E={($report | Measure-Object -Property CapacityMB -Sum).Sum}}

$report


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

0 Kudos
DevKhurana
Enthusiast
Enthusiast
Jump to solution

Thanks, This is exactly what I want.

0 Kudos