If you have read many of my articles on this site, you might have noticed that I tend to use Notepad when creating and editing PowerShell scripts. Although Notepad does tend to be my go-to editor for reasons I will explain in a moment, it certainly isn’t the only option. In this article, I want to show you some of the various options that are available to you.
PowerShell script editors
As I mentioned earlier, Notepad is usually my go-to tool for editing PowerShell scripts. On occasion, I have received sharp criticism for using Notepad as a PowerShell editor because Notepad is really just a text editor. That means that It doesn’t have any of the PowerShell-specific features you might find in a dedicated editor. Even so, there are three reasons why I like using Notepad.
First, Notepad is a part of Windows and is installed by default. If I am working on a different computer than normal, I know that Notepad is already on that computer. I can get on with what I need to do without having to take the time to install an editor.
Second, Notepad has a very clean, minimalist interface. I find it to be really easy to read. You can see what PowerShell code looks like within Notepad in the figure below.
The third reason why I like using Notepad is because it’s super lightweight. It loads almost instantly, as opposed to some of the other tools that take a few seconds to load.
PowerShell ISE is the default tool for editing PowerShell code, as I’m sure you already know. As you can see in the figure below, PowerShell ISE is far more feature-rich than Notepad.
There are several advantages to using PowerShell ISE as opposed to a less capable tool like Notepad. For instance, PowerShell ISE has a PowerShell console built into the editor. It also provides command help and syntax highlighting. As you can see in the previous figure, PowerShell ISE even gives you the ability to collapse blocks of code, which can be useful if you are working with an excessively long script.
Visual Studio Code
Visual Studio Code is a free, multiplatform code editing tool provided by Microsoft. Microsoft makes this tool available on Windows, Linux, and macOS and provides regular updates.
There are two main things that I really like about Visual Studio Code (aside from the fact that it is free). First, Visual Studio Code supports portable installations. That means that you can install it onto removable media (such as a USB flash drive) and use it as needed.
The other thing that is really nice about Visual Studio Code is that it supports a wide variety of extensions. There are extensions for languages such as C++, Java, Python, and tool extensions for ESLint, JSHint, and PowerShell. There are also several debuggers and keymap extensions available.
Even without an extension, Visual Studio Code supports syntax highlighting for PowerShell. As you can see in the figure below, however, Visual Studio Code automatically recognizes that I have loaded a PowerShell script and offers to install the PowerShell extension.
In case you are wondering, the PowerShell extension adds several things to Visual Studio Code, including support for code snippets and IntelliSense. Perhaps more usefully, the PowerShell extension adds a PowerShell interface to the console. You can see what this interface looks like in the figure below.
Visual Studio Professional
Visual Studio Professional is Microsoft’s tool of choice for professional developers, although the company also offers a community edition and an enterprise edition. Unlike Visual Studio Code, which is free, Visual Studio Professional comes with a price tag: $45 per month or $1,199 per year (with subscription renewals costing $799 per year).
Because Visual Studio Professional is geared toward professional developers, it is extremely feature-rich. At the same time, though, there is a learning curve associated with using Visual Studio Professional. And if I am to be completely honest, Visual Studio Professional is overkill for PowerShell.
Even so, PowerShell is fully supported by Visual Studio Professional. As you can see in the figure below, Microsoft offers PowerShell Tools for Visual Studio. The tools give you the ability to edit, run, and debug PowerShell scripts using the Visual Studio debugger, among a few other things.
Another free option for creating and editing PowerShell scripts is Notepad++. Even though I haven’t spent as much time using Notepad++ as some of the other options, I have been really impressed with it so far.
Notepad++ is specifically designed for use in development tasks, and as you can see in the figure below, it provides syntax highlighting for PowerShell.
What I really like about Notepad++ is that it is essentially a development tool for non-developers. Visual Studio and similar tools have all the features that professional developers need. Still, as someone who does not build applications for a living, I have no idea how to use most of those features. Notepad++, on the other hand, is feature-rich, but most of its features are easy to use. The learning curve for Notepad++ is minimal.
PowerShell script editors: Use the one you like best
So which editor is best for building and editing PowerShell code? In all honesty, I think it all comes down to personal preference. If you are starting out with PowerShell, then PowerShell ISE may be the best choice because it provides quite a bit of help with commands. Conversely, those who are more experienced might be better off using Visual Studio Code or Notepad++. Of course, the editors I have discussed in this article are far from being the only options. There are many other free and paid editors available, each with their own unique features.
Featured image: Designed by Vectorjuice / Freepik
More PowerShell Basics articles
- PowerShell Gallery: A great free resource for finding scripts
- Using JSON with PowerShell: A guide for IT professionals
- Reading text files with PowerShell and Linux bash shell
- How malicious PowerShell scripts evade detection
- Building PowerShell hash tables