The details of the event scenario and the design points for Beginner Event #10 of the 2012 PowerShell Scripting Games can be found on the “Hey, Scripting Guys! Blog”.
Gather all of the counter information for the processor counter set. Take three separate readings at five second intervals. This information should be appended to a single text file named servername_ProcessorCounters.txt in the Documents special folder. You’ll lose points for complexity. Use native PowerShell commands where possible.
This was the most confusing event for me since it specified “Processor Performance Counter Set” in one of the design points and my home pc with an AMD processor has a “Processor Performance” counter set:
Comparing the results of what the “Processor Performance” counter set returned on my pc to the screenshot provided in the scenario requirements assisted me in determining that what they were really asking for was the information in the “Processor” counter set.
I spent a lot of time trying to figure out how to sort my data as shown in the screenshot provided in the scenario requirements of this one. I happened to come across a Hey, Scripting Guy! Blog article on “Use PowerShell to Simplify Collecting Performance Information” that showed how to accomplish the proper sorting.
The second difficult part was figuring out what the Documents special folder was? I found another blog article titled “The Easy Way to Use PowerShell to Work with Special Folders” on the Hey, Scripting Guy! Blog that helped and then all I had to do was put the pieces together. I initially used “Combine” to combine the Documents special folder with the server name and file name but that didn’t use native PowerShell commands. I also had to figure out that an escape character (the grave accent or back-tick) was needed after the $Env:ComputerName variable to use it as part of the file name as shown below:
While looking at other people’s scripts for Beginner event #3, I found a reference to using Join-Path by one of the judges. I had used the same method as that person but didn’t receive that sort of feedback so I was lucky I found this. Here’s the script I submitted: