Setting Up Visual Studio Code for PowerShell

After watching a webinar recently where the presenter was using Visual Studio Code to run PowerShell codes he prepared for the demo, it strikes me that maybe it’s time to ditch PowerShell ISE and start using Visual Studio Code for all my coding needs.

Setting up VS Code for PowerShell turns out super easy.

First, download VS Code from https://code.visualstudio.com and install it, if you haven’t done so.

Then, launch VS Code and head over to the Extension menu on the left or press Ctrl + Shift + X.

Search for “PowerShell” in the list, select it and click Install on the right side.

Believe it or not, there are almost 6 million downloads already as of today. It seems there are more than enough people really into using Visual Studio Code for PowerShell as well.

Open Settings menu and make sure PowerShell:Start Automatically is checked so the extension starts automatically when a PowerShell file opens.

And that’s all you need to get it started.

Right off the bat, there are two ways to run the code you wrote. You can highlight the code you want to run, either full or part of it, right-click anywhere in the window and choose Run Selection or simply press F8 key.

Or, press Ctrl + Shift + P to bring up the Command Palette and choose Terminal: Run Active File in Active Terminal.

As to why VS Code over PowerShell ISE, check out this post from Learn PowerShell.

Leave a Reply

Your email address will not be published. Required fields are marked *