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 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 strategy. She also serves as executive editor of the group's media Web sites, and you'll even find her byline on PureAI.com, the group's newest site for enterprise developers working with AI. She recently gave a talk at a leading technical publishers conference about how changes in Web technology may impact publishers' bottom lines. Follow her on twitter @beckynagel.


  • Ransomware: What It Means for Your Database Servers

    Ransomware affects databases in very specific ways. Joey describes the mechanics of a SQL Server ransomware attack, what DBAs can do to protect their systems, and what security measures they should be advocating for.

  • Windows Admin Center vs. Hyper-V Manager: What's Better for Managing VMs?

    Microsoft's preferred interface for Windows Server is Windows Admin Center, but can it really replace Hyper-V Manager for managing virtual machines? Brien compares the two management tools.

  • Microsoft Offers More Help on Windows Server 2008 Upgrades

    Microsoft this week published additional help resources for organizations stuck on Windows Server 2008, which fell out of support on Jan. 14.

  • Microsoft Ups Its Carbon Reduction Goals

    Microsoft on Thursday announced a corporatewide carbon reduction effort that aims to make the company "carbon negative" by 2030.

comments powered by Disqus

Office 365 Watch

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.