Uncategorized

How to switch from PowerShellISE to VSCode

Windows PowerShell ISE can be used to create PowerShell scripts. It’s still available on Windows, and Microsoft has confirmed that they don’t plan to remove the ISE. It’s not in active feature development anymore and doesn’t work with PowerShell 6 or higher.

Visual Studio Code is probably already installed. If you are not, you should. VSCode is a cross-platform, lightweight code editor that is free and easy to use. It is available for Windows and macOS as well as Linux. It is available for download here. It is open-source and has many extensions. You can find them all here.
PowerShell is one of my favourite extensions. It offers syntax highlighting and IntelliSense cmdlets, which is very similar to PowerShell ISE. PowerShell Preview was recently updated to make it easier to transition from PowerShell ISE into VSCode.
VSCode can be customized by either using the Settings editor or editing the underlying settings.json files. You can configure VSCode to behave and look more like PowerShell ISE. There are many write-ups. Using the PowerShell Preview extension you can achieve that familiar look and feel by simply enabling ISE Mode. Equally important, disabling ISE Mode will return VSCode to its original settings so that you don’t lose any of your VSCode customizations.
PowerShell Preview will not work if you are using the PowerShell extension.

PowerShell Preview can be downloaded from the extensions marketplace.

After installing the extension, you will be able to choose the color theme for PowerShell ISE. I chose not to, as I prefer the customizations I have made to VSCode. To keep your current settings, choose your current color theme.

Close the PowerShell Preview tab, the extensions marketplace, and then return to your normal workspace. Next, press Ctrl+Shift+P and you will be able to open the command menu. You will see the commands to enable or disable ISE Mode in the command palette search bar.

Select PowerShell: Enable the ISE Mode, and VSCode is transformed into the familiar PowerShellISE. The PowerShell blue background with white font, white script pane across top, and the command-explorer sidebar. This is so cool!

If you’re a stickler for details, you might be thinking, “Hey Mike! Wasn’t that command bar on PowerShell ISE?” And you would be right. You’re not alone! It is possible to fix it if it bothers your. Just right-click the command explorer titlebar and choose Move Sidebar Right. This is part of VSCode, and works with all sidebars.

I will show you how to disable ISE Mode before you do (you already know it, haven’t you? PowerShell Preview extension has additional features that make it feel similar to PowerShell ISE.
Two icons will appear if you hover over or select one command in the command explorer.

Clicking on the question mark icon will take you to the docs.microsoft.com site for the cmdlet or open help within the console. I haven’t figured out why it does either one or the other.

Clicking on the pencil icon will insert your cmdlet into the script pane.

PowerShell Preview also includes IntelliSense. You will see pop-up syntax assistance if you hover over the cmdlet you have just inserted.

As you type, you’ll be able to see the parameters available.

Open the command palette and type ISE mode to return to normal VSCode. Next, choose PowerShell: Disable ISE Mod (restore defaults).

ISE Mode was created to make it easier to transition from PowerShell ISE into VSCode. They have done an amazing job. ISE Mode is only part of the PowerShell Preview extension. ISE mode is not required if you don’t want the PowerShell ISE look. You can disable ISE mode and still get the PowerShell Preview extension.
The PowerShell icon can be used to access the command explorer even ISE Mode is disabled. You can still access help and insert cmdlets using the command explorer. IntelliSense still provides syntax assistance while you type. Enjoy your customized VSCode environment.

If you still use PowerShell ISE to create your scripts the PowerShell Preview extension can help you make the transition. This extension is for you if you are familiar with VSCode and need to create PowerShell scripts.
ITProTV offers online training in PowerShell Basics or PowerShell Scripting if you want to learn more about PowerShell.