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.


  • How To Configure Windows 10 for Intel Optane Memory

    Intel's Optane memory technology can significantly improve the performance of your Windows 10 system -- provided you enable it correctly. A single mistake can render the system unbootable. Here's how to do it the right way.

  • Microsoft and SAP Enhance Partnership with Teams Integration

    Microsoft and SAP this week described continuing partnership efforts on Microsoft Azure, while also planning a Microsoft Teams integration with SAP's enterprise resource planning product and other solutions.

  • Blue Squares Graphic

    Microsoft Previews Azure IoT Edge for Linux on Windows

    Microsoft announced a preview of Azure IoT Edge for Linux on Windows, which lets organizations tap Linux virtual machine processes that also work with Windows- and Azure-based processes and services.

  • How To Automate Tasks in Azure SQL Database

    Knowing how to automate tasks in the cloud will make you a more productive DBA. Here are the key concepts to understand about cloud scripting and a rundown of the best tools for automating code in Azure.

comments powered by Disqus