Q&A
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.
About the Author
Becky Nagel serves as vice president of AI for 1105 Media specializing in developing media, events and training for companies around AI and generative AI technology. She also regularly writes and reports on AI news, and is the founding editor of PureAI.com. She's the author of "ChatGPT Prompt 101 Guide for Business Users" and other popular AI resources with a real-world business perspective. She regularly speaks, writes and develops content around AI, generative AI and other business tech. Find her on X/Twitter @beckynagel.