2012 Scripting Games Beginner Event 10: Collect Performance Counter Information

Dr Scripto

 2012 Scripting Games badge

Summary: In Beginner Event 10, you are required to collect performance counter information about your CPU.

About this event



Date of Event

4/13/2012 12:01 AM

Due Date

4/20/2012 12:01 AM

Event scenario

You are a network administrator for a small company, and you are attempting to monitor a transient problem with CPU spiking on one of your servers. You decide that rather than running the performance monitor or task manager, you want to use Windows PowerShell to collect the performance counter information. You do not have time to manually choose a bunch of counters, but you want to gather all of the counter information from the processor counter set. You should take three separate readings at five-second intervals. All of the counter information should be appended to a single text file that is named after the server and placed in the Documents special folder. An appropriate output is shown in the image that follows.

Image of command output

Design points

  • You can write the performance counter information directly to a text file named after the server. Place the text file into the Documents special folder. The file name will look like the following: servername_ProcessorCounters.txt.
  • Your command should retrieve all of the performance counter information from the Processor performance counter set.
  • You do not need to write a long convoluted script to meet the requirements of this scenario. You will lose points for long, complicated, hard-to-read scripts.
  • A “one liner” command can be written that will satisfy the requirements of this scenario.
  • You should use native Windows PowerShell commands for this scenario where possible.

2012 Scripting Games: All Links on One Page

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. Good luck as you compete in this year’s Scripting Games. We wish you well.

Ed Wilson, Microsoft Scripting Guy 


Comments are closed. Login to edit/delete your existing comments