I'm new to PWSH, it may looks easy for you guys but I can't find the way to show the result as expected.
$vm2 = Get-VM VM1234
$vmMemUsageAvg = get-VM $vm2.Name | Select @{N="Mem.Usage.Average";E={[Math]::Round((($_ |Get-Stat -Stat mem.usage.average -Start (Get-Date).AddHours(-24)-IntervalMins 5 -MaxSamples (12) |Measure-Object Value -Average).Average),2)}}
Now, as example, when requesting the result of $vmMemUsageAvg
I receive this output:
C:\Windows\system32> $vmMemUsageAvg
Mem.Usage.Average
-----------------
5.9
but I want only want as output the value, like: 5.9
putting that in Excel cell with
$Sheet.Cells.Item($intRow, 13) = [String]$vmMemUsageAvg
gives me a string like this:
@{Mem.Usage.Average=5.9}
Any help welcome to have this value ONLY displayed