VMware Cloud Community
FGShepherdP10
Enthusiast
Enthusiast
Jump to solution

Resource Pool Reporting

I'm working on a report (to be published via HTML) that will show the MemReservationMB of all Resource Pools (RP) in a cluster, then loop through any VMs within that RP and add up all of the RAM assigned to those VMs.  Afterward, I want to know how much MemReservationMB is left to that RP, if any, for new VMs or expansion of current ones.

So far, I have both halves, which show the RP stat and the sum of all VMs.  What I cannot figure out is how to do the basic subtraction step afterward.  It appears that PowerShell can handle operations with raw numbers, but not with variables.

Has anyone else run into this?

Thanks in advance...

Bonus points:
Ultimately, I'd like to also sum up all disk usage by VM in each RP, so if anyone wants to tee that one up...

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You're trying to do arithemtics with an object.

Do

$RP = Get-VM -name "AUTOM005*" | Get-ResourcePool | select  -ExpandProperty MemReservationMB

instead


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

View solution in original post

4 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

Can you show the script that you already have? Maybe we can find what is wrong.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos
FGShepherdP10
Enthusiast
Enthusiast
Jump to solution

Just doing this in pieces for the moment, where $VMSum is the Sum of all RAM assigned to VMs in a RP, and $RP is getting the Reserved RAM on a RP:

$VMSum = Get-VM -name "DeptID*" | Measure-Object -Property MemoryMB -Sum | select Sum

$RP = Get-VM -name "AUTOM005*" | Get-ResourcePool | select MemReservationMB

...looking for "$RP [minus] $VMSum"

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You're trying to do arithemtics with an object.

Do

$RP = Get-VM -name "AUTOM005*" | Get-ResourcePool | select  -ExpandProperty MemReservationMB

instead


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

FGShepherdP10
Enthusiast
Enthusiast
Jump to solution

Worked perfectly.  LucD strikes again!

Reply
0 Kudos