I work on a script to get values needed for a checkup of vCenter properties and data, automaticaly via PowerShell script.
At the moment I am at a point where I want to get the average memory usage of all hosts in % as realtime value from the last entry, so you as user you can see all averages and can check them like: if one host would die would the other or one other be capable of replacing him without getting over 100% mem usage.
That's the easy part I use:
Get-Vm |
Get-Stat -Stat mem.usage.average -Realtime -MaxSamples 1 |
select Value,Unit
and the output is
Value Unit ---- 0,99 % 0,99 %
My desired output would look like this
Name Value Unit ----- - ---- Test1 0,99 % Test2 0,99 %
I tried to include
Get-Vm | select Name
which gives me exactly the missing part of my desired output, but I am not so sure how I could include it to be like the desired output.
Get-Stat
provides you the Entity
. So you could use:
Get-Vm |
Get-Stat -Stat mem.usage.average -Realtime -MaxSamples 1 |
select Entity, Value,Unit