You have been putting off making the switch from PowerShell ISE to VSCode. Who has time to learn a new environment? Well, now may be the time. The PowerShell extension for VSCode has been updated, and it makes replicating the ISE experience in VSCode as easy as flipping a switch.
Windows PowerShell ISE is a great tool for developing PowerShell scripts. It is still available for Windows and Microsoft has stated they have no plans to remove the ISE from Windows. However, it is no longer in active feature development, and does not work with PowerShell 6 and higher.
Hopefully, you are already using Visual Studio Code. If not, you should be. If you are not familiar with VSCode, it is a free, lightweight, cross-platform code editor. It is available for Windows, macOS and Linux. You can download it here. Built on open source, it has a rich ecosystem of extensions, which you can browse here.
One of my favorite extensions is the PowerShell extension. It provides syntax highlighting and IntelliSense for cmdlets, very similar to PowerShell ISE. Recently, a major update to the PowerShell extension was released, PowerShell Preview, and it will make transitioning from PowerShell ISE to VSCode even easier.
VSCode is very customizable, by using either the Settings editor or by editing the underlying settings.json file. There are several write-ups on how to configure VSCode to look and behave more like PowerShell ISE. However, with the new PowerShell Preview extension, you can get that familiar look and feel by simply enabling ISE Mode. Equally important, disabling ISE Mode returns VSCode to your original settings, so you will not lose all your VSCode customizations.
Install the PowerShell extension
If you are currently using the PowerShell extension, you will need to disable it before you enable PowerShell Preview for best performance.
Search the extensions marketplace for PowerShell and install PowerShell Preview.
When you install the extension, it will give you the choice to set the color theme to PowerShell ISE. I choose not to; I like the customizations I have done to VSCode already. Choose your current color theme to keep your current settings.
Enable ISE Mode
Close the PowerShell Preview tab and the extensions marketplace and return turn to your normal workspace. Then type Ctrl+Shift+P to open the command palette. In the command palette search bar, type ISE mode and you will see the commands to enable and disable ISE Mode.
Select PowerShell: Enable ISE Mode, and VSCode will be transformed into that familiar PowerShell ISE. The terminal with the PowerShell blue background and white font, the white script pane across the top, and the command explorer sidebar! How cool is that?
Now if you are a stickler for detail, you might be saying “Hey Mike, wasn’t the command bar on the right side in PowerShell ISE?” You would be correct, it was. But guess what? If you prefer the sidebar on the right, it is easy to fix. Simply right-click on the command explorer title bar and choose Move Side Bar Right. (This is part of VSCode and works with all the sidebars)
Before I show you how to disable ISE Mode (you have figured it out already, haven’t you?), there are more features of PowerShell Preview extension I want to point out, that make it feel like PowerShell ISE.
Explore the Features
If you hover over or select one of the commands in the command explorer, you will see two icons.
Clicking the question mark icon will either take you to the docs.microsoft.com page for that cmdlet or open help in the console. (I have not figured out when or why it does one or the other)
Clicking the pencil icon will insert the cmdlet into your script pane.
Do not forget about the IntelliSense that PowerShell Preview adds. If you hover over the cmdlet that was inserted, you will see pop-up syntax help.
As you type, you will get help with the available parameters.
Disable ISE Mode
When you are ready to return to your normal VSCode environment, open the command palette, type ISE mode, and choose PowerShell: Disable ISE Mode (restore to defaults).
The idea behind ISE Mode is to ease the transition from PowerShell ISE to VSCode, and they have done an amazing job. Keep in mind, ISE Mode is just part of the PowerShell Preview extension. If you do not want that PowerShell ISE look and feel, you do not have to use ISE mode. You can leave ISE mode disabled, and still take advantage of the PowerShell Preview extension.
With ISE Mode disabled, the command explorer can be accessed using the PowerShell icon in the sidebar. You can still access help and insert a cmdlet using the command explorer and IntelliSense still provides syntax help while typing. All while enjoying your customized VSCode environment.
So, if you are still using PowerShell ISE to create your scripts, the PowerShell Preview extension for VSCode can help ease the transition. If you are already working with VSCode and need to write PowerShell scripts, this extension will make it easier. Now is the time to switch from PowerShell ISE to VSCode!
Make sure to check out more great articles at ITProTV
Comments are closed