Hey everyone,
I am having issues with trying to figure out how to calculate and display the %%% RAM used on my vHosts in a cluster, this is what I have so far:
$reportRDCWH = Get-Cluster 'RDC-Production-Windows' | Get-VMHost | Select-Object @{e={$_.name};L="vHost"},
And what issues do you have?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am trying to take the Total RAM and Total Used and find the %%% in another column.
And where is this $reportRDCWinVMs variable coming from?
I'm afraid I don't see the logic behind your code.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sorry that was a mistake in my variable, it should look like this:
I assume you want to do something like this.
But I'm not sure why you are calculating the percentage with Get-Stat, you can just derive it from the Total and Usage.
In any case I included both options, pick the one you want
$reportRDCWH = @()
$reportRDCWH += Get-Cluster 'RDC-Production-Windows' | Get-VMHost | Select-Object @{e = { $_.name }; L = "vHost" },
@{e = { $_.NumCpu }; L = "vCPU's" },
@{e = { [math]::Round($_.MemoryTotalGB,1) }; L = "RAM(GB)" },
@{e = { [math]::Round($_.MemoryUsageGB,1) }; L = "RAM(Used)" },
@{N = 'RAM_USed(%)'; E = {[math]::Round($_.MemoryUsageGB / $_.MemoryTotalGB * 100,1) }},
@{N = 'RAM_used_stat(%)'; E = {[math]::Round((Get-Stat -Entity $_ -Stat 'mem.usage.average' -Realtime -MaxSamples 1).Value,1) } } |
Sort-Object -Property vHost
$reportRDCWH += "" | Select-Object @{L = 'vHost'; E = { 'Total' } },
@{N = "vCPU's"; E = { $reportRDCWH | Measure-Object -Property "vCPU's" -Sum | Select-Object -ExpandProperty Sum } },
@{N = "RAM(GB)"; E = { $reportRDCWH | Measure-Object -Property "RAM(GB)" -Sum | Select-Object -ExpandProperty Sum } },
@{N = "RAM(Used)"; E = { $reportRDCWH | Measure-Object -Property "RAM(Used)" -Sum | Select-Object -ExpandProperty Sum } },
@{N = "RAM_USed(%)"; E = { $reportRDCWH | Measure-Object -Property "RAM_USed(%)" -Average | Select-Object -ExpandProperty Average } },
@{N = "RAM_used_stat(%)"; E = { $reportRDCWH | Measure-Object -Property "RAM_used_stat(%)" -Average | Select-Object -ExpandProperty Average } }
$reportRDCWH
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference