Category: Scripting Games

Announcing the Winner of the PowerShell TFM Book Contest

Two weeks ago, I started a PowerShell contest which required the participants to convert a string of text to title case. I didn't specifically say title case but I explained that the first letter of each word should be converted to upper case and all remaining letters in each word should be converted to lower case. This was because a search on how to convert to title case with PowerShell gave away a good portion of the answer. There were a total of 22 entries in the contest and all of them were Read more [...]

Windows PowerShell TFM Book Contest and Giveaway

Today is the first day of Autumn also known as fall here in North America and it's my favorite time of the year. If nothing else, you've got to love the cooler weather and the changing of tree leaf colors. Last fall, a new version of the Windows PowerShell TFM book that I co-authored along with Jason Helmick was published and strangely enough, its design is remarkably similar to the colors that are associated with Autumn. SAPIEN Technologies who is the publisher of the book is providing one Read more [...]

My Solution: August 2015 PowerShell Scripting Games Puzzle

A couple of months ago, PowerShell.org announced that the PowerShell Scripting Games had been re-imagined as a monthly puzzle. In August, the second puzzle was published. The instructions stated that a one-liner could be used if you were using a newer version of PowerShell. A public JSON endpoint can be found at http://www.telize.com/geoip and your goal is to write some PowerShell code to display output similar to the following: Try to accomplish this with a Read more [...]

My Solution: July 2015 PowerShell Scripting Games Puzzle

Last month, PowerShell.org announced that the PowerShell Scripting Games had been re-imagined as a monthly puzzle and the first puzzle was published. The instructions stated to use a PowerShell one-liner that produces the following output. No more than one semicolon should be used, do not use the ForEach-Object cmdlet or one of its aliases. The one-liner should be able to target more than one computer and feel free to go crazy with a really short one-liner with aliases and whatever else. Although Read more [...]

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: When the previous command is run, all of Read more [...]

PowerShell Tip #3 from the Winner of the Advanced Category in the 2013 Scripting Games

In my previous blog article (PowerShell Tip #2), I left off with the subject of inline help and stated there was a better way. I'm fast-forwarding through lots of concepts and jumping right into "Advanced Functions and Scripts" with this tip because they are where you'll find the answer to a "better way" to add inline help. The inline comments we saw in the previous tip looked like this: When looking at the syntax for this function, you can see that it has no parameters: CmdletBinding Read more [...]

PowerShell Tip #2 from the Winner of the Advanced Category in the 2013 Scripting Games

Tip #2 - Comment (Document) your code! This is another one of those tips that probably isn't very popular, but regardless of how good you are at writing PowerShell scripts and functions, they're useless if no one else can figure out how to use them. You might be thinking that you're the only one who uses the PowerShell code that you write, but I'm sure that you like to go on vacation just like the rest of us and none of us are going to live forever. In my tip #1 blog you learned that you Read more [...]

PowerShell Tip #1 from the Winner of the Advanced Category in the 2013 Scripting Games

In case you haven't heard, the 2014 Winter Scripting Games are just now getting started. Regardless of your skill level with PowerShell, it couldn't be a better time to participate since this is the first time in the history of the scripting games that you'll be able to work as part of a team and receive proactive feedback (before your code is judged) from a team of expert coaches who use PowerShell in the real world on a daily basis. Ultimately, the scripting games make learning PowerShell more Read more [...]

Introducing the Coaches of the 2014 Winter Scripting Games

A few weeks ago, just before the announcement to start recruiting your team for the 2014 Winter Scripting Games, I was contacted by Don Jones and Richard Siddaway about an opportunity to become the Head Coach for the Winter Scripting Games. I was honored to have been contacted and I'm a firm believer of taking advantage of opportunities when they emerge, especially when they're PowerShell related, so I graciously accepted. One of my first responsibilities was to recruit a small team of coaches. Read more [...]

PowerShell Parameter Validation: Building a Better ValidatePattern with ValidateScript

Let's start out by taking a look at what the PowerShell built-in help says about the ValidatePattern and ValidateScript validation attributes: Here's what that help topic says about ValidatePattern: We'll test using ValidatePattern with an example that I used in my entry for advanced event #4 in the Script Games this year as shown in the following example: Who knows what that regular expression does? The guy who wrote this might, but probably no one Read more [...]

How to Create PowerShell Script Modules and Module Manifests

My entry for the Scripting Games advanced event 4 contained four separate functions: I want to create a module that contains these functions. There are several different types of modules, but what I'll be creating is a "Script Module". Modules sound like something really complicated, but script modules are actually simple. Currently, I have the functions saved as a ps1 file which I dot-source to load the functions into memory, but I want to share this tool with others so it makes more sense to Read more [...]

Using a Counter Variable in a PowerShell Workflow Foreach -Parallel Loop

As I'm sure most of my blog readers are aware, I competed in the advanced track of the Scripting Games this year and ended up doing quite well. Two first place finishes and three second places finishes with the official judges and four first place crowd score finishes. I also ended up being the overall winner of the advanced track. A few days ago someone on twitter asked me as the winner of the Scripting Games advanced track, what I would do with it? I plan to use it as a tool. I'll continue doing Read more [...]

2013 PowerShell Scripting Games Advanced Event 6 – The Grand Finale

For me, the Scripting Games have been a great learning experience this year. I've used many PowerShell features that I hadn't used before such as splatting, ADSI, Workflows, and producing html webpages with PowerShell. I plan to write detailed followup blog articles on each of these topics over the next few months. Event 6 was definitely challenging since I hadn't used workflows before but I also knew that's what was really needed to accomplish the given task properly (In my opinion). While you Read more [...]