2012 Scripting Games Advanced Event 10: Create a CSV Log File

 2012 Scripting Games badge

Summary:  In Advanced Event 10, you want to create a CSV log file of all the counters in the Processor counter set.

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 server admin, and you are concerned about the processor performance of one particular server. You decide to use Windows PowerShell to create a CSV log file of all the counters in the Processor counter set. You decide to take the counter snapshot at two-second intervals for a total of ten snapshots. You plan to analyze the data in a Microsoft Excel spreadsheet. An acceptable output is shown in the figure that follows. Create the CSV file in the Documents special folder for the current logged-on user. The file name should be servername_processorCounters.csv.

Image of command output

Design points

  • Make sure that you include all of the counters for all instances of the processor object.
  • Make sure that the saved CSV file is readable from within Microsoft Excel.
  • Make sure that you get the number of snapshots with the prescribed time between snapshots.
  • This can be a “one liner” single logical command. Do not write complex, difficult-to-understand script because you will lose points.

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

  1. mredwilson says:

    @Jaap Brasser that is minutes, seconds and milliseconds.

  2. K_Schulte says:

    Hi Ed,

    on first sight … this one seems to be an easy task!

    The second design point is confusing me … why shouldn't the output be readable by Excel?

    The last point is quite clear … but: What about error handling, comment based help ….?

    Looking at the first column of the spreadsheet … my output won't be identical!

    Have you made any changes after loading the results in excel before you took the picture?


  3. Anonymous says:

    Ugh.  I don't have a clue where to start on this one…  (well, I have some ideas, but I don't know how to make it look pretty like that, especially with a one-liner).  Time to get my research hat on!

  4. K_Schulte says:

    @John: NO!

    You can only participate in ONE category!


  5. Anonymous says:

    What time zone is the 'Due Date', I've worked out it is several hours behind my time, though missed a few cut-offs due to not being certain. Would be useful knowing.

  6. Anonymous says:

    Thanks for the clarification on the Timezone, though unfortunately I still managed to miss it for Event 7 by 3 minutes.  Oh well, at least I still learnt lots. :o)

    With this one however, on my system (Win7 x64) there is no 'documents' special folder. Should this be 'mydocuments' ??

  7. JohnGrenfell says:

    I don’t seem to be able to submit a script for this event.

    I get the error "Data Errors •You can only submit one script per event!"

    I’ve already submitted to Beginner 1-10. Are you allowed to post for both Beginner and Advanced Events (if you feel up to it)?

  8. Anonymous says:

    Scratch my previous comment – got it!  Helpful hint:  Use Get-Command to look up relevant cmdlets.  There are some you may not know exist ;).

  9. Jaap Brasser says:

    Thanks for clarifying IamMred.

  10. Jaap Brasser says:

    Cell A1 looks like some disfigured timestamp to me. Not sure what it is supposed to represent.

  11. Cameron Wilson says:

    What is the value of cell A1?  As in, what is the data in that cell supposed to represent? Originally, I had it populated with the hostname of the machine but I see that is "EDLT" in the image and am now sure what (PDH-CSV ??) is…  I'm done except for this part.

  12. Peter says:

    When exporting to CSV the German Excel likes a ; as a delimiter otherwise all columns are jammend into one cell. May be thats meant with "readable output"

    Whats wrong with complex scripts by the way (as long as I know whats going on;)

  13. Ed Wilson says:

    The timezone is PST  (-8 UTC)

Skip to main content