15 October 2012

Read performance counters from powershell

in good old command prompt typeperf can be used but from what i manged to test is not working ok on windows 2003 (it is not returning process description; it return just counters event if i use some letters and * wildchar and should return more than one process);

use typeperf /? or technet (http://technet.microsoft.com/en-us/library/bb490960.aspx) for usage information;

with powershell we have Get-Counter cmdlet but the use of * wildchar and letters at the same time is not supported on windows 2003 and XP;

best sollution i found was to use WMI from powershell:


Get-WmiObject win32_PerfFormattedData_PerfProc_Process -Filter "Name like 'powersh%'" | Select-Object Name, PercentProcessorTime


Name                      PercentProcessorTime
----                            --------------------
powershell               98
powershell#1           0


No comments:

Post a Comment