As with any scripting or programming language, choosing an ideal editor can make or break one’s coding experience. Functionality, usability, and aesthetics—in accordance with personal preference—are critical. Productivity and adherence to best practices depend on balanced tooling. Users often require the following:
A workbench or repository for projects—allowing quick access to files
An organized, readable text editor for scripting
Some sort of linter or script analyzer
Options for debugging
Time-saving tools like auto-completion and quick replacements
We often view development with a modern lens. However, PowerShell is no spring chicken—having debuted in 2006. Numerous developers have since contributed to the ecosystem. Many editors and IDEs have emerged to tackle problems or rethink longstanding processes. We’ll evaluate some popular options, and why PowerShell professionals might gravitate to them instead of the basic Command Line.
Visual Studio Code in PowerShell ISE Mode (image courtesy of Thomas Maurer)
Because Visual Studio is more of a comprehensive IDE geared toward applications, many developers have embraced Visual Studio Code (VSC) as a friendlier replacement. Accordingly, VSC topped the list of popular development environments in Stack Overflow’s 2019 Developer Survey—over 50.7% of respondents use it. The application should be familiar to many, and is otherwise a stellar starting point for newer PowerShell professionals.
VSC is highly customizable. Apart from its rich marketplace for visual tweaks, the editor offers a number of functional extensions. One key extension is PowerShell Language Support—distributed via the Visual Studio Marketplace. It allows developers to activate an integrated ISE Mode. This is done easily through the command palette, by typing “ISE Mode.” In the popup list, choose “PowerShell: Enable ISE Mode.”
The extension is compatible with all Linux PowerShell Core distributions, macOS or OS X with PowerShell Core, and Windows 7+. These Windows variants must run PowerShell Core and PowerShell 3 or newer. Users may also leverage the Command Line and Terminal to install these extension packages. VSC and its add-ons are both free and open source.
Out with the Old, in with the New
But why the move towards ISE Mode? For a long time, PowerShell ISE was the default application for Windows users. Unfortunately, standalone ISE is no longer in development. Microsoft thus thought it necessary to provide that familiar functionality within its flagship editor. Conveniently, Visual Studio Code’s settings menu lets users configure it like PowerShell ISE—down to its appearance and functionality.
VSC is a worthy PowerShell editor. It’s easy to replicate color schemes, console execution behavior, tab completion, and file assumptions. The app now includes a command explorer. Learning how to harness hotkeys is turbulence-free within VSC, and PowerShell commands are plentiful. Debugging is also available. VSC leverages its own IntelliSense hinting-and-completion tool for cmdlets and related code.
Users will feel at home with its interface, with minimal effort. While some applications force users to adapt, VSC is good at ‘getting out of its own way’ for the developer’s sake. That simple, distraction-free approach is great for productivity.
Sapien PowerShell Studio 2020
Fig. 2: Sapien PowerShell Studio 2020
PowerShell Studio by Sapien is an actively-supported IDE for PowerShell only. While quite expensive at $399, Studio sells itself as a universal solution for all PowerShell needs. This holds true whether one runs 32-bit or 64-bit PowerShell. PowerShell Studio also supports STA and MTA modes—important considerations for legacy objects, and GUI tools or scripts. The software itself features a GUI Designer for low-code creation.
Note that PowerShell Studio only supports Windows. Linux and macOS (and OS X versions) aren’t compatible. Sapien also offers PrimalScript. This program is a full-fledged, multi-language IDE—and while it supports PowerShell, its functionality is more limited.
The suite features a capable editor, which also features code completion and auto-formatting. It also includes essentials like syntax coloring, bookmarking, and reference highlighting. Those working with remote modules will love Studio’s editor—as scripting with associated cmdlets is possible. A major contributor to all of this is the Function Builder. Complex parameter-and-cmdlet attributes are easy to write; the Function Builder automatically inserts proper syntax as needed.
Studio also includes the usual suspects, like script debugging, module creation, and integrated PowerShell consoles. The application sets itself apart by including supplemental debugging methods:
Users can also perform other powerful functions within PowerShell Studio: executable and installer creation. Developers can customize their privileges and elevations. MSI installers are also fair game. This level of functionality isn’t universal across the PowerShell tooling landscape. Speaking of which, Studio provides real-time script performance monitoring. Those curious about CPU and memory usage are armed with knowledge.
Finally, the suite provides some useful goodies like Universal Version Control and file recovery. These features make it easier to revert to prior versions, while safeguarding all progress made.
Fig. 3: Notepad++ editor (image courtesy by Kloud)
While Notepad++ isn’t a default Windows application like its cousin, Notepad, the application features expanded functionality that’ll satisfy admins. Thankfully, it’s still easy—and free—to download Notepad++ via the Microsoft Store or directly. The application only supports Windows. However, both 32-bit and 64-bit binaries are provided.
Notepad++ offers essentials like syntax highlighting for PowerShell, and does so within a clean editing environment. Auto-indenting for PowerShell is available. Furthermore, a host of development functions are included by default—without the addition of extensions.
Despite this, Notepad++ is primarily built to be two things: lightweight and user-friendly. The editor consumes few system resources while allowing one’s PC to “throttle down and reduce power consumption.” It’s built to execute quickly while taking up less disk space. The features in Notepad++ are generally simple to use—lessening the learning curve, even when coming from another product.
Notepad++ is exceptional for core PowerShell scripting tasks. It’s also more welcoming to new developers than other alternatives.
Choosing a PowerShell Partner in Crime
Selecting the proper PowerShell editor is a highly-personal choice. Every developer has their own workflows, preferences, and objectives related to programming. There’s a bevy of options out there—certainly more than we’ve listed—yet these choices remain popular and well-received. One’s proficiency level may also determine their tooling direction.
So, you’ve got PowerShell editing down, but what if you need a complete PowerShell-management solution? ScriptRunner is a leading solution for centralizing, automating, and monitoring performance. PowerShell priorities don’t stop there, however. The right solution must be secure and usable. For IT pros and DevOps pros alike, ScriptRunner remains a premier solution for PowerShell’s most-dedicated users.
Professional script development in a team
Do you want to develop PowerShell scripts easily and securely in a team or multiple teams?
In this webinar, we’ll show you how joint scripting accelerates the development process and opens up new opportunities for automation and delegation.
https://www.scriptrunner.com/wp-content/uploads/2021/03/powershell-best-practices.png10001000Philip Lorenzhttps://www.scriptrunner.com/wp-content/uploads/2018/05/ScriptRunner_Logo_RGB-300x45.pngPhilip Lorenz2021-03-10 10:00:042021-03-10 15:22:175 PowerShell Scripting Best Practices – From Runnable to Professional CodeScriptRunner Software GmbH
https://www.scriptrunner.com/wp-content/uploads/2020/12/xmas-fun-powershell.jpg10001000Bruno Buyckhttps://www.scriptrunner.com/wp-content/uploads/2018/05/ScriptRunner_Logo_RGB-300x45.pngBruno Buyck2020-12-23 10:00:412021-01-07 16:26:55X-mas Fun with PowerShell and ScriptRunner