Export (0) Print
Expand All
Tip: Use Windows PowerShell to Monitor System Performance


A new feature in Windows 7 is the ability to use Windows PowerShell for gathering performance data. Three new Windows PowerShell cmdlets provide functionality as follows:

Follow Our Daily Tips

Tell Us Your Tips
Get-counter Gets real-time performance counter data from local and remote computers.
Import-counter Exports PerformanceCounterSampleSet objects as performance counter log (.blg, .csv, .tsv) files.
Export-counter Imports performance counter log files and creates objects that represent each counter sample in the log.

For example, the following Windows PowerShell command gets the current “% Processor Time” combined values for all processors on the local computer every 2 seconds until it has 100 values and displays the captured data:
PS C:\Users\mallen>Get-counter -Counter "\Processor(_Total)\% Processor Time" -SampleInterval 2 -MaxSamples 100

The following command continuously gets the current “% Processor Time” combined values for all processors on the local computer every second (the default sampling interval) and displays the captured data until you press CTRL+C:
PS C:\Users\mallen>Get-counter -Counter "\Processor(_Total)\% Processor Time" –Continuous

You can pipe the output of the Get-counter cmdlet into the Export-counter cmdlet.For example, the following command gets the current “% Processor Time” combined values for all processors on the local computer every 2 seconds until it has 100 values and exports the captured data as a performance counter log file named Data1.blg, which is saved in the current directory (here the root folder of user Michael Allen’s user profile):
PS C:\Users\mallen>Get-counter "\Processor(*)\% Processor Time" -SampleInterval 2 -MaxSamples 100 | Export-counter -Path $home\data1.blg

You can also pipe the output of the Import-counter cmdlet into the Export-counter cmdlet. You might do this, for example, to convert a performance monitor log file from one format to another, such as from .csv to .blg format.

From the Microsoft Press book Windows 7 Resource Kit by Mitch Tulloch, Tony Northrup, Jerry Honeycutt, Ed Wilson, and the Windows 7 team.

Looking for More Tips?

For more tips on Windows 7 and other Microsoft technologies, visit the TechNet Magazine Tips library.




Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft