Writing Better PowerShell Code
Recently, a friend of mine announced a new PowerShell module he had published to the PowerShell Gallery. Naturally, I had to take a look at his code. Like many of you, he has a specific area of expertise and has picked up PowerShell scripting skills over the years to complement his expertise. He has learned enough PowerShell to be able to automate tasks in his domain of expertise. His code works, but while looking at it, I realized it could be better.
Often, the difference between writing good PowerShell code and better code is nothing more than experience. The more you write and learn, the better your code becomes. Of course, there’s always the challenge of “I don’t know what I don’t know.” I trust that is one of the reasons you subscribe to this newsletter. You are hoping to learn things you didn’t know existed.
During my poke around his GitHub repository, I recognized a few things that often trip up less experienced PowerShell scripters. This makes for a great “teaching opportunity” for everyone.