Exploring Visual Studio Code as a PowerShell ISE Alternative
Microsoft has deprecated PowerShell ISE, leading users to consider alternatives such as Visual Studio Code, which provides features like syntax highlighting and an ISE mode.
April 19, 2024
For years, PowerShell Integrated Scripting Environment (ISE) has been the primary tool on Windows for scripting in PowerShell. Even so, Microsoft has deprecated this feature and will no longer add more functionalities. Although Microsoft has stated that PowerShell ISE will remain in Windows for the time being, it is no longer supported in PowerShell version 6 and higher.
Given PowerShell ISE’s uncertain future, it’s worth exploring alternative development platforms.
As strange as it may sound, I never use PowerShell ISE when developing PowerShell code. Instead, I write the majority of my code in Notepad. While Notepad lacks features such as the terminal window and syntax highlighting, I like it because it is super lightweight and easy to read.
Of course, you can write PowerShell code in nearly any text editor, and there are plenty of editors that have far more features than Notepad. Editors like Notepad++, UltraEdit, and Sublime Text come to mind, but there are many others to choose from.
What Is Visual Studio Code?
For those seeking a PowerShell ISE-like development experience, the current go-to tool from Microsoft is Visual Studio Code (https://code.visualstudio.com/). Unlike Visual Studio, Visual Studio Code is free and doesn’t require a subscription. Better still, like PowerShell, Visual Studio Code offers cross-platform compatibility, available for on Windows, MacOS, and Linux, with a web version also provided by Microsoft.
Perhaps the most notable difference between Visual Studio Code and PowerShell ISE is that it is not limited to PowerShell. Visual Studio Code provides native support for JavaScript, Python, Java, Markdown, Typescript, C/C++, JSON, PowerShell, HTML / CSS C#, PHP, and YAML. Additionally, it has a huge number of supported extensions, with some pre-installed by default.
Setting Up Visual Studio Code
Although Visual Studio Code is powerful and feature-rich, setting it up for the first time might not be the most intuitive process. Upon launching Visual Studio Code, you will be prompted to select a theme. Once you have done that, click on the folder icon and then the “Add a Folder” link, as shown in Figure 1. When prompted, select the folder where you will store your PowerShell scripts, and then click Add. Your chosen folder will now be added to the console tree.
To create a new file, hover over the folder you just added and then click on the “New File” icon. When prompted, enter a filename, including the PowerShell script extension. For example, I entered Demo.ps1 as the filename.
If your filename includes the .PS1 file extension, Visual Studio Code will recognize that you intend to write PowerShell code and automatically prompt you to install the PowerShell extensions, as shown in Figure 2.
Upon clicking the Install button, Visual Studio Code will install everything you need for writing PowerShell code. However, as you can see in Figure 3, the main window also gives you an option to install PowerShell 7 if desired. Although PowerShell 7 is indeed the latest version of PowerShell, it is designed to be cross-platform, and so therefore lacks some of the Windows-specific cmdlets.
Syntax Highlighting and ISE Mode
Now that the PowerShell extension has been installed, there are two more things I would like to highlight about the editor. First, if you look back at Figure 3, you will notice that the main window is tabbed. Since this is the first time that I have used the editor with PowerShell, a Welcome tab was automatically created. Additionally, there is a separate tab for my Demo.ps1 file. In Figure 4, you can see that Visual Studio Code uses syntax highlighting for the code that I have written. There is also a Terminal window located at the bottom of the screen.
Another feature of Visual Studio Code worth highlighting is its inclusion something called ISE mode. If you return to the Welcome tab and scroll down, you will find an option to try ISE mode, shown in Figure 5.
Enabling ISE mode transforms Visual Studio Code’s appearance to closely resemble that of PowerShell ISE. This mode even grants access to PowerShell ISE’s Command Explorer. You can see how ISE mode looks like in Figure 6.
As previously noted, there’s no pressing need for you to make the switch to Visual Studio Code. PowerShell ISE is not going away any time soon, and you can still opt for a text editor if you prefer. Nevertheless, Visual Studio Code offers extensive support for multiple languages, works across different platforms, and offers development features that surpass those found in PowerShell ISE.
About the Author(s)
You May Also Like