Tag: Scripting Games

2013 PowerShell Scripting Games Advanced Event 2 – Why NOT to use the Win32_ComputerSystem WMI Class

The majority of the entries I've seen for the Scripting Games event 2 are using the TotalPhysicalMemory property from the Win32_ComputerSystem WMI class to determine the total amount of physical memory in a server. The property name is "TotalPhysicalMemory" after all so that's what it should contain, right? Not so fast, keep reading to discover why. Your manager needs an inventory of all of your company's physical servers that are located in three different data centers which are in different Read more [...]

2013 PowerShell Scripting Games Advanced Event 2 – Attention to Detail is Everything

Here's my approach to the 2013 PowerShell Scripting Games Advanced Event 2: When I start one of the Scripting Games events, I read and re-read the scenario because if you don't understand the requirements, you can't write an effect script, function, command, tool, etc. It's not a bad idea to print out the event scenario and highlight the high-points. Here's the scenario for Advanced Event 2 -An Inventory Intervention, I'll place the items in bold that I would normally highlight on my printout: Dr. Read more [...]

Lessons Learned from the Scripting Games Advanced Event 1

This is a continuation from my previous blog titled "2013 PowerShell Scripting Games Advanced Event 1 – Parameters Don’t Always Work As Expected". This isn't the exact script, but sections of it. You'll notice at the bottom of the first image shown below, I retrieve the list of folder names from the files variable to keep from having to make another call to the file system. Going from one variable to another in memory is a cheap operation where as going to disk to retrieve something is more Read more [...]

2013 PowerShell Scripting Games Advanced Event 1 – Parameters Don’t Always Work As Expected

The scenario for this event states the following which has been paraphrased: Someone allowed log files to build up for around two years and they're starting to causing disk space issues on the server. You need to build a tool to archive the log files because this has happened more than once. Applications write log files to a sub-folder in "C:\Application\Log". Examples are C:\Application\Log\App1, C:\Application\Log\OtherApp, and C:\Application\Log\ThisAppAlso. The log files have random file Read more [...]

The Scripting Games are Coming, The Scripting Games are Coming, The Scripting Games are Coming!

This years Scripting Games are scheduled to be kicked off during the PowerShell Summit North America 2013 which begins on April 22nd. That's about two and a half weeks away at this point. In previous years, there have been two categories and it's my understanding that this year, there will be three categories. One for PowerShell beginners, one for advanced PowerShell scripters as in previous years, and a new category for people who aren't actually competing in the events but want to grade or rate Read more [...]

Interesting How People are Claiming to Have Same Beginner 1 Solution as the Expert Solution but Still Did Not Get 5 Stars

This past weekend I posted a blog about Beginner Event #9 of the 2012 PowerShell Scripting Games and I received a comment on it from @ruddawg26. I took a look at his profile and tweets. I found a tweet that was tweeted by him "Interesting how people are claiming to have same beginner 1 solution as the expert solution but still did not get 5 stars #2012SG" so I decided to investigate further which is how this blog came to be. There's a blog article on the Hey, Scripting Guy! blog: "Expert Commentary: Read more [...]

Performance Counters – 2012 PowerShell Scripting Games Beginner Event #10

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 Read more [...]

Search Event Log – 2012 PowerShell Scripting Games Beginner Event #9

The details of the event scenario and the design points for Beginner Event #9 of the 2012 PowerShell Scripting Games can be found on the “Hey, Scripting Guys! Blog”. Find Veto Shutdown Events in the Application Event Log. A screenshot was provided that contains EventID 10001 and Winsrv as the source. Write a one liner to display the date of occurrence and the application name. Your command should be efficient. Complexity will cost you points. As noted in the comments section of this scenario, Read more [...]

Determine Hardware Type – 2012 PowerShell Scripting Games Beginner Event #8

The details of the event scenario and the design points for Beginner Event #8 of the 2012 PowerShell Scripting Games can be found on the “Hey, Scripting Guys! Blog”. Write a script to determine if a computer is a laptop or a desktop from a hardware prospective and display the output on the console. If this requires admin rights, you should detect if it is running as an admin or standard user. Extra points for writing a simple function that returns a boolean. I kind of figured this was going Read more [...]

Enabled Logs with Data – 2012 PowerShell Scripting Games Beginner Event #7

The details of the event scenario and the design points for Beginner Event #7 of the 2012 PowerShell Scripting Games can be found on the “Hey, Scripting Guys! Blog”. Display a list of enabled logs that contain data. Do not display errors. Include hidden logs. Display the complete log name and number of entries. Sort by the logs with the most entries in them. My research on this one lead me to the "Use PowerShell to Query All Event Logs for Recent Events" blog article on the Hey, Scripting Read more [...]

Working with WMI – 2012 PowerShell Scripting Games Beginner Event #6

The details of the event scenario and the design points for Beginner Event #6 of the 2012 PowerShell Scripting Games can be found on the “Hey, Scripting Guys! Blog”. Write a PowerShell script to determine the uptime of servers by using the WMI class WMI32_OperatingSystem. The script should display the server name, how many days, hours, and minutes the server has been up. As usual, I started out by running Get-Help Get-WMIObject to determine what the available parameters were for this Read more [...]

Finding Application Errors – 2012 PowerShell Scripting Games Beginner Event 5

The details of the event scenario and the design points for Beginner Event #5 of the 2012 PowerShell Scripting Games can be found on the “Hey, Scripting Guys! Blog”. Your manager has task you with producing a report of applications that are causing errors on your servers. This report should display the source and number of errors from the application log. How can I find out what PowerShell cmdlets are available to query the application event log? I could certainly use Get-Help, but I Read more [...]

Just Passing Thru – 2012 PowerShell Scripting Games Beginner Event 4

The details of the event scenario and the design points for Beginner Event #4 of the 2012 PowerShell Scripting Games can be found on the “Hey, Scripting Guys! Blog”. The key to this one is figuring out how to format the output as shown in the screen shot in the event scenario which is similar to the one in the image below: The PowerShell Down Under guys posted some great prep videos leading up to the beginning of the scripting games and one of them titled "Scripting Games 2012 - Working Read more [...]

Toughest Event Yet – 2012 PowerShell Scripting Games Beginner Event #3

The details of the event scenario and the design points for Beginner Event #3 of the 2012 PowerShell Scripting Games can be found on the “Hey, Scripting Guys! Blog”. This was the toughest event out of the first three for me. I spent a lot of time researching how to check permissions because part of the first design point stated: "If you do not have permission off the root, create the nested folders where you have permissions". This was clarified in the comments section later during the day Read more [...]

Get-Method | My-Madness | 2012 PowerShell Scripting Games Beginner Event #2

The details of the event scenario and the design points for Beginner Event #2 of the 2012 PowerShell Scripting Games can be found on the “Hey, Scripting Guys! Blog”. Listed below are my notes about the requirements and design points: Find all services that are running and can be stopped. The command must work against remote computers. Use the simplest command that will work. You do not need to write a script. Return the results to the screen, not to a file. You may use aliases. I started Read more [...]

My Approach to the 2012 PowerShell Scripting Games Beginner Event #1

The details of the event scenario and the design points for Beginner Event #1 of the 2012 PowerShell Scripting Games can be found on the “Hey, Scripting Guys! Blog”. Listed below are my notes about the requirements and design points: Computers run Windows 7 and servers run Windows 2008 R2. They’re all in one domain. PowerShell remoting is enabled on all computers (both servers and desktops). Use PowerShell to retrieve the top ten processes based on the memory working set. There’s no Read more [...]