2012 Scripting Games Beginner Event 10: Collect Performance Counter Information

 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 links

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 (14)

  1. mredwilson says:

    @Jeff Wouters yes, you have it right.

    @SoCalDavis – that is why I included it. It is useful to use, and not too difficult once you know the "secret"

    @SteveH yes, run it local on the computer.

  2. mredwilson says:

    @Mark P we can change it to Beginner.

  3. Anonymous says:

    @aalaminos – That would be sweet if that's what they mean… but I'm not so sure since they say "the Documents special folder". If they said "a special folder under Documents", then I would be confident with your thought. I have been searching for hours on this one… has me stumped so far.

  4. Anonymous says:

    The Documents "special" folder is not the easiest thing for me to figure out.

  5. JohnGrenfell says:

    I’m judging my progress in the PS games by how much I’ve learnt and this event has taught me a lot I didn't know about collecting performance counter information with Powershell.

    Thanks Guys!

  6. Anonymous says:

    Actually, I am going with my first thought regarding the "special" folder (and what someone else thought).

  7. Anonymous says:

    @SoCalDavis & @aalaminos: I think they mean this kind of special folder: en.wikipedia.org/…/Special_folder

  8. Jeff Wouters says:

    Sorry, a bit confused again… Got my script finished but just want to get something clarified before uploading the script…

    What is meant with "You should take three separate readings at five-second intervals"?

    The interval I understand, but what about the seperate readings? For example, at 16:00:00 reading one, at 16:00:05 reading two and at 16:00:10 reading three?

  9. aalaminos says:

    @Jeff Wouters I understand the same , you can take three samples "readings" at five-second intervals (not more than three).

    @JSoCalDavis I think that we can create a special folder to store the "servername_ProcessorCounters.txt"

    @John Grenfell  In this post before the comments you can see the Tags, click the "performance" tag and you can learn a lot of things about "work with performance counters"

  10. JoshuaSTaylor says:

    HOLY CRAP! I'd have to say that, for me at least, writing to the Documents special folder has been the most difficult challenge of the games. I don't do much file output from PS so this was pretty new to me. I think I'm going to start using it a lot more now. 🙂 I <3 Scripting Games

  11. SteveH says:

    Can we assume that the script will be run locally on the problem server, or should we be able to run the script again a remote computer?

  12. Dawn Villejoin says:

    Definitely learned a good bit of helpful tidbits after doing this event! Truly addicted to powershell!!

  13. Mark P says:

    Ack, submitted my script to the advanced event #10 instead – and now I can't upload it to the beginner event.

  14. Mark P says:

    Thanks! The games have been a blast this year!

Skip to main content