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
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
Have a good day.
$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) }}
$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) }}
Works flawless!
Thank you, very much. I was close.. But could not get it put together correctly.
Again thanks.