Chapter 3. WWPD: what would PowerShell do?

 

Before you dive into scripting and toolmaking, it’s worth having a conversation about “The Right Way to Do Things.” One of PowerShell’s advantages—and also one of its biggest disadvantages—is that it’s pretty happy to let you take a variety of approaches when you code. If you’re an old-school VBScript person, PowerShell will let you write scripts that look a lot like VBScript. If you’re a C# person, PowerShell will happily run scripts that bear a strong resemblance to C#. But PowerShell is neither VBScript nor C#; if you want to take the best advantage of it and let it do as much heavy lifting for you as possible, you need to understand The PowerShell Way of doing things. We’re going to harp on this a lot in this book, and this is where we’ll start.

3.1. Writing single-task tools

3.2. Naming tools

3.3. Naming parameters

3.4. Producing output

3.5. Don’t assume

3.6. Avoid innovation

3.7. Summary