Scripting Games

Scripting Games
Boe Prox
Scripting Games

Using PowerShell Parameter Validation to Make Your Day Easier

A number of entries in the Winter Scripting Games use parameter validation, but some that I have seen may not be using it correctly or to its full potential. Writing functions or scripts require a variety of parameters which have different requirements based on a number of items. It could require a collection, objects of a certain type or even a certain range of items that it should only accept.

Richard Siddaway
Scripting Games

Scripting Games event 1 close

Event 1 is over and the judging is complete. First off congratulations to every team that posted an entry - the events in these games are different and we’ve tried to up the challenge level to account for it being a team based. The high scorers for event 1 are: 1.Troll Bait with 22 points 2.Kitton Mittons with 22 points 3.Aliens with 20 points 4.PhillyPosh with 20 points 5.Thanks4TheInvite with 17 points

Jonathan Medd
Scripting Games

Reporting On Installed Windows Programs Via The Registry

Quite a common request for working with Windows machines is to report the software installed on them. If you don’t have a centralised system for reporting on client software (many places don’t) then you may turn to some form of scripted method to obtain this information. Most people tend to head to Add / Remove Programs when thinking about what software is installed in Windows. However, not all applications will always populate information in there, depending on how they have been installed.

Don Jones
Scripting Games

The Scripting Games Winter 2014 – Update on Event 1 Scores

Note that scorecards for the first event will not be accurate immediately on Sunday when judging closes; we have the scores in the database, but they’re not tagged in a way the system can find them. The bug has been fixed, but I need to go through and manually re-tag the first day’s scorecards, and it’s going to take a couple of days. This also affect the leaderboard display. I hope to have it fixed over the weekend.

Mike F Robbins
Scripting Games

PowerShell Tip from the Head Coach of the 2014 Winter Scripting Games: Design for Performance and Efficiency!

There are several concepts that come to mind when discussing the topic of designing your PowerShell commands for performance and efficiency, but in my opinion one of the items at the top of the list is “Filtering Left” which is what I’ll be covering in this blog article. First, let’s start out by taking a look at an example of a simple one-liner command that’s poorly written from a performance and efficiency standpoint:

Jonathan Medd
Scripting Games

Adding and Removing Items from a PowerShell Array

Adding and removing Items from a PowerShell array is a topic which can lead to some confusion, so here are a few tips for you. Create an array and we will note the type System.Array: Click here to be redirected to the original post of this article on the author’s blog site where you can read the remainder of the article.

Jonathan Medd
Scripting Games

Testing for Admin Privileges in PowerShell

Sometimes when running a PowerShell script you may need to test at the beginning whether the process it was called from had Windows admin privileges in order to be able to achieve what it needs to do. Prior to PowerShell v4 I had used something along the lines of the following to test for this condition – not the most obvious piece of code ever to be fair: Click here to be redirected to the original post of this article on the author’s blog site where you can read the remainder of the article.

Boe Prox
Scripting Games

Winter Scripting Games 2014 Tip #2: Use #Requires to let PowerShell do the work for you

In Version 2 of PowerShell, you had the ability to use #Requires –Version 2.0 to ensure that your scripts/functions would only run at a specified PowerShell version to prevent folks running an older version from wondering why things weren’t working that well. In this article, I will show you a couple of new additions to the #Requires statement that will make your life easier when writing functions that require specific pre-requisites rather than coding your own methods

Richard Siddaway
Scripting Games

Scripting Games 2014 – event submission tip

I’ve testing out the judging system using the practice event and one thing jumped out at me. It was a lot easier to understand the entries for those teams that included a transcript of their entry. I would very strongly recommend that you include a transcript of your entry running. As a minimum I would recommend that you include: the solution running - show each type of input required by the scenario (pipeline, single values, file etc) if parameter validation is asked for - show that in action show error handling in action if you can show the partial contents of any output file

Boe Prox
Scripting Games

Winter Scripting Games 2014 Tip #1: Avoid the aliases

Having been a judge for the previous 2 Scripting Game competitions as well as competing in the 2 before that, I have seen my share of scripts submitted that didn’t quite meet the cut of what I felt were the best scripts. It doesn’t mean that they wouldn’t work out in the real world in a production environment (Ok, some wouldn’t :)), but some were just really hard to read or others were doing things that I wouldn’t consider to be a good practice.