Don Jones on Everything You're Doing Wrong in PowerShell
Thinking scripts instead of functions is just one of the many ways you're missing out on the true power of PowerShell.
Don Jones is one of the preeminent PowerShell MVPs, authors and trainers. And if anyone knows what you (and the rest of the IT world) is doing wrong in PowerShell, he does.
So we caught up with him ahead of his session, "Everything You're Doing Wrong in PowerShell," at Live! 360 this December in Orlando to find out a bit more about what most people are doing wrong (and right) with Microsoft's ubiquitous task automation framework.
What is the No. 1 thing that IT admins do wrong in PowerShell and why is it so bad?
Writing monolithic scripts instead of modular, advanced functions. People end up working way harder than they need to, and they produce things that miss out on all the work PowerShell itself is willing to do for you.
What is No. 2?
Treating PowerShell like a programming language. It has one, sure, but it's not C# and it's not VBScript. Understanding and embracing that is not only key to being more efficient, it's key to avoiding most of PowerShell's weirder gotchas.
What is your No. 1 best practice when it comes to PowerShell, either for beginners or for longtime pros who've maybe gotten into some bad habits?
Don't try to invent new usage patterns that contradict the ones already in the shell. People tend to do this inadvertently because they've not taken the time to understand the native patterns, and they end up coding themselves into some mighty ugly corners.
"The key with doing things 'right' in PowerShell is to understand why PowerShell exists and what it was meant to solve. It's a tool, and like any tool, there are right and wrong times and places to use it."
Don Jones, PowerShell MVP
What is the correct approach for advance functions?
Follow the native patterns. An advanced function is a command, just like a cmdlet, and should look and feel the same as one.
What is a quirk or two about PowerShell that you think might trip people up sometimes, or lead to bad habits?
It's got some stuff in it, like the "return" keyword, that can make you think it's a language like C#. It isn't. Honestly, even the product team regrets some of those decisions, because it gets people working in an entirely wrong direction.
What else do you want to share with our readers about your "Everything You're Doing Wrong in PowerShell"session before it takes place in Orlando in December?
The key with doing things "right" in PowerShell is to understand why PowerShell exists and what it was meant to solve. It's a tool, and like any tool, there are right and wrong times and places to use it. That's really what the session hits on.
Becky Nagel is the vice president of Web & Digital Strategy for 1105's Converge360 Group, where she oversees the front-end Web team and deals with all aspects of digital projects at the company, including launching and running the group's popular virtual summit and Coffee talk series . She an experienced tech journalist (20 years), and before her current position, was the editorial director of the group's sites. A few years ago she gave a talk at a leading technical publishers conference about how changes in Web browser technology would impact online advertising for publishers. Follow her on twitter @beckynagel.