VMware Cloud Community
GlenTrust
Contributor
Contributor
Jump to solution

Count total Configured memory in each cluster

Hi,

I'm fairly new still, to Powershell and PowerCLI, but im trying to learn.

I'm playing around with, trying to extract some data from my vCenter and its going well for now, with some help from this site and alot of google'ing Smiley Wink

But now im running into a little bit of a problem, I would like to Count total amount of Configured memory in each cluster. And this i have soleved with this code:

$confimem = Get-Cluster |

Select Name,

   @{N="Total Configured Memory GB";E={

  [Math]::Round(($_ | Get-VM | %{$_.MemoryMB} |

  Measure-Object -Sum | Select -ExpandProperty Sum)/1KB,1)

}}

And this is giving a good result. But now im thinking, this is also counting all the VM's in the cluster, that is Powered Off, the Templates and all that. What i would like to do is only include VM's that is powered on.

And I was thinking something like: Where-Object {$_.PowerState -eq "PoweredOn"} But I'm not experienced enough to find out how to put this together.

Any body want to help me solve this? I would be very happy Smiley Happy

Have a good day.

0 Kudos
1 Solution

Accepted Solutions
kunaludapi
Expert
Expert
Jump to solution

$confimem = Get-Cluster | Select Name, @{N="Total Configured Memory GB";E={[Math]::Round(($_ | Get-VM | Where-Object {$_.PowerState -eq "PoweredOn"} | %{$_.MemoryMB} | Measure-Object -Sum | Select -ExpandProperty Sum)/1KB,1) }}

--------------------------------------------------------------- Kunal Udapi Sr. System Architect (Virtualization, Networking And Storage) http://vcloud-lab.com http://kunaludapi.blogspot.com VMWare vExpert 2014, 2015, 2016 If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".

View solution in original post

0 Kudos
2 Replies
kunaludapi
Expert
Expert
Jump to solution

$confimem = Get-Cluster | Select Name, @{N="Total Configured Memory GB";E={[Math]::Round(($_ | Get-VM | Where-Object {$_.PowerState -eq "PoweredOn"} | %{$_.MemoryMB} | Measure-Object -Sum | Select -ExpandProperty Sum)/1KB,1) }}

--------------------------------------------------------------- Kunal Udapi Sr. System Architect (Virtualization, Networking And Storage) http://vcloud-lab.com http://kunaludapi.blogspot.com VMWare vExpert 2014, 2015, 2016 If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".
0 Kudos
GlenTrust
Contributor
Contributor
Jump to solution

Works flawless!

Thank you, very much. Smiley Happy I was close.. But could not get it put together correctly.

Again thanks.

0 Kudos