简体   繁体   中英

powershell RAM high water mark

Is there a way to get the high water mark of RAM usage in powershell? Running on a 2008 R2 System.

I was thinking I would have to write a script to turn on RAM counters, then use powershell to query? Make sense? Any examples?

-Ken

There is no Peak Memory Used counter for the entire box, but you can query the /Paging File/% Usage Peak. You may find this gives an indication of whatever event you're trying to monitor.

$categoryName = 'Paging File'                   
$counterName = '% Usage Peak'
$instanceName = '_Total'

$counter = "\$categoryName($instanceName)\$counterName"
Get-Counter $counter

There is also a set of Peaks for each running process. If there's a particular service you're interested in (like inetinfo), then query for /Process(inetinfo)/Virtual Bytes Peak, Working Bytes Peak, Page File Bytes Peak. The odds are this will get you closer to your real goal, anyway, of finding out where your memory's being consumed.

If neither of those does what you want, then you'll need to set up an actual counter log. This can be done programmatically via PowerShell (if you're trying to do this in bulk against a number of machines), but it's usually easier just to use the PerfMon Control Panel Applet. If you save that data to a .csv, you can then use PowerShell to analyze for maximum values of significant columns.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM