This site uses advanced css techniques
I've been using PowerShell for more than a decade, but it was only a few years ago that I started tapping the power of creating my own cmdlets for integrating into business processes. These are wildly powerful and have changed how I think about and solve problems for my customers.
Over time I've collected a large set of techniques, tips, and tricks that have made my life easier, so I'm documenting them here. I'm not trying to create start-from-scratch tutorials, but addressing things that I had to solve the hard way, including things that were really easy but nevertheless took me way too long to trip over.
I'd like this to be a go-to resource for advanced PowerShell cmdlet development.
I am calling these "CmdLetters" ("command letters") as a play on words. Ha ha.
I do all my development with (generally) the most recent PowerShell, and not all these techniques will work on older versions. I'll try to make notes about version dependencies when I know about them, but most of my customers operate with newer operating systems, so I don't take too many steps to account for legacy systems.
I do all my develoment on Windows 10 (either my main desktop or my laptop) using Visual Studio 2017, and I generally target the .NET 4.6.1 framework. I don't have a good reason for choosing that framework other than it appears to have been a good tradeoff on what my customer systems had available.
Note: In these pages I've intentionally chosen to focus on the main point of the article, and in some cases avoiding other best practices that would distract from the primary topic. I'll note these.
In a number of places, I've also avoided more advanced C# mechanisms that might have been more compact, but not as easy to follow, leaving it as an exercise to the reader to improve or optimize.
In addition, I'm confident I'm missing out on other best practices or features of the language simply due to my own ignorance: as I learn more, I'll write about it.
I certainly welcome feedback from others others on missed opportunities.
I've been building cmdlets for a long time, but with a different perspective than most, and that informs my style.
Though built to solve customer problems, I am typically the user of the cmdlets as well as the author, so I've made almost no provisions for organized packaging or product-ization.
This means that I'm missing out on a range of technologies I should be using, such as packaging in modules or creating reasonable help files.
I'm also typically only refining them enough to solve the problem at hand, as my customers aren't paying me to build a product either: you'll find the very strong aroma of ad hoc in almost everything I build.
I do hope to up my game on this front, but I go where my projects take me.