If I look in Task Manager, I can see "In Use" memory.
I know that I can grab performance information in PerfMon
, but I do not know which counter in Perfmon retrieves this value.
I want to write a PowerShell script to find out average memory usage for the past day. PerfMon is the only option that I can think of. Is there a better way to do this in PowerShell?
Get-Counter -Counter
is the way to get performance counters in PowerShell 2+. "In use" looks like it's the rounded value of Total Memory - Available
:
[math]::Round(((((Get-Ciminstance Win32_OperatingSystem).TotalVisibleMemorySize * 1kb) - ((Get-Counter -Counter "\Memory\Available Bytes").CounterSamples.CookedValue)) / 1GB),1)