Search code examples
performancevirtual-machinepowercli

VM powercli - how to get the custom field / object


I have job to get the following ESXi host information, while I am coding the powercli, I need to get the consumed CPU Mhz, but there is no field to get the value directly, so I custom a field and write some formula to caculate it, Called "Host CPU - Mhz". However, the following information will write into the excel file, I have some confuse how to get the custom field in the powercli

here is my part of code

$hostState = "" | get-vm | where-object {$_.VMHost -match '10.0.0.100'} | select Name, PowerState, @{N="Host CPU - MHz";E={[Math]::Round(($_ | get-stat -stat cpu.usagemhz.average -Start (Get-Date).AddDays(-1) -IntervalMins 1440 | Measure-object Value -Average).Average,2)}}

$hName = $hostState.Name
$hPowerState = $hostState.PowerState
$hCPU = << how to do it?>>

kindly advice and help.


Solution

  • $hCPU = $hostState."Host CPU - MHz"