2012 Scripting Games Beginner Event 5: Provide a Source and Errors

 2012 Scripting Games badge

Summary: In Beginner Event 5, you are required to provide the source and number of errors from the application log.

 About this event



Date of Event

4/6/2012 12:01 AM

Due Date

4/13/2012 12:01 AM

Event scenario

You are a junior server admin on a newly formed team at a medium-sized enterprise company. Your manager is attempting to gain an understanding of which applications are causing problems on your servers. He therefore tasks you to produce a report from each server. The report should list the source and the number of errors from the application log on each server. An appropriate output is shown in the following image.

Image of command output

Design points

  • Your solution should be capable of running against a remote machine, but you do not need to do that for this scenario.
  • You do not need to check for admin rights. Assume that you will have permissions to query the application log on the computer.
  • You should use standard Windows PowerShell cmdlets.
  • Your solution does not need to be long, involved, or complicated. It should be simple and straightforward.
  • You do not need to write to a text file, but your solution should be easily redirectable to a file when needed.
  • You do not need to add comment-based Help.
  • Extra points for sorting the output so that the source with the greatest number of errors appears on the top of the list.

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

  1. mredwilson says:

    @Ncoppersmith the requirements for this exercise can be met on all platforms that run Windows PowerShell 2 or grater.

  2. mredwilson says:

    @Rumart two points means that the script meets the basic requirements of the scenario. 1 point means that it does not meet the requirements. Each of the additional design points either add or take away from a specific score. The judges are really struggling to keep up with the number of scripts — we have more than twice the number of submissions this year as last. There are many places where you can find out about the judges coments- for exqample some of my blog posts. Next week, there will be expert commentaries on the scenarios. In addition, many of the judges are posting things they are seeing on their blogs. We will be having a list of Judges blogs soon.

  3. Anonymous says:

    Remind me again what you mean by "comment-based Help". Does that just mean that we don't need to include comments in the script?

  4. mredwilson says:

    @K_Schulte No you will not get extra points for the opposite of "you do not need to" because this event already has four specific items that you SHOULD do. Each of these items is 1 point, and you always get 1 point for submitting, so there is the five points. This event can be solved with a one-linner, in which aliases would be acceptible. I stated that you can assume you have rights, so you do NOT need to check for rights. You COULD however, use a cmdlet to ensure your remote comptuer is reachable, prior to doing the query for the errors if you wish. That would be a nice extra touch, but do not ignore the four YOU SHOULD DO … design points.

  5. Anonymous says:

    A remark from a beginner… I've got 2 points on my script for this event. I don't complain about the score, I'm in this to learn.. But what really would be great is a comment from the judges when the score is that low.. If you don't get to know what you do wrong, it is difficult to learn.. With that said, I do realise that the judges have a lot to do..

  6. mredwilson says:

    @Daveyk per the FAQ blogs.technet.com/…/faq-for-the-powershell-2012-scripting-games.aspx You cannot change your script once it is submitted. Sorry. This is one reason you have 7 days for each script, to give you time to work through it before you post it.

  7. K_Schulte says:

    Hi Ed,

    a lot of questions are on my mind for this event!

    It looks pretty simple on first sight …

    Well: "you do not need to …" — does this say: "But if you do, you'll get extra points?" 🙂

    "…query the application log …" — does this mean: query ONLY the application log? … or all classic logs ? or …

    "… not need to be long, involved, or complicated …" — does this say: "You may use aliases this time"?

    -> this helps, at least regarding shortness :-))

    At least you didn't mention "error handling" … should we add some anyway?


  8. Anonymous says:

    Not to complicated after I figured it out! I have to give "Get-Help" all the credits though.. 😉

  9. Anonymous says:

    This looks really complicated to start off but once you actually start reading into the cmdlet it's fairly straight forward.  Feeling very confident about this one, hopefully my first 4 star script!

  10. mredwilson says:

    @Mr Killian yes. This one is not too horribly complicated.

  11. mredwilson says:

    @Marc W this scenario can be solved using a one-linner. YOu should not have to write a long complicated script.

  12. mredwilson says:

    @Patches_McMatt comment based help take a look at these Hey Scripting Guy blog articles blogs.technet.com/…/searchresults.aspx

  13. mredwilson says:

    @Andre Actually the Scripting Wife is a bit off here. The scenario clearly states that you only need to query the application log on the computer. In addition, that query should use technology that could work against a remote computer, but for this secenario you do not need to do so. Pay attention to how you illustrate this to the judges in your script, and choose a good default value.

  14. Marc W says:

    Are you doing a one liner or a full blown script?

  15. Scott Baker says:

    I agree with Mr Killian, it actually took a lot less time to figure this one out than I thought it would.  

    @K-Schulte, I think they have mentioned previously that aliases are OK in one-liners, but not OK in scripts.  Also this event says that your code should be simple and straightforward–to me that means don't add a bunch of fluff, just make it do what is requested.

  16. Daveyk says:

    If I submit a script with an error.  EG: It runs, but produces incorrect results, how do I delete it and resubmit?

  17. NCoppersmith says:

    In prior events, it was stated which platforms were being used.  Since that is not present here (that I see) does the command need to work in an XP/2003 environment, or can we assume Vista/7/2008?

  18. Andre says:

    Hello Ed,

    I don't want to create problems between you and your wife but she says:

    "Not just the big three (System, Security, and Application)—but any event log that is created by using the old-fashioned type of technology."

    and you say:

    "The report should list the source and the number of errors from the application log on each server. " without a "s" at the end of log.

    So, do I get information from all the logs or only the Application log ?

    Thanks for your work which gives us a funny oportunity to progress.


Skip to main content