Using PowerShell 7 in VS Code

If you haven’t heard, PowerShell 7 has been released! Even if you haven’t gotten emails or RSS alerts, it’s hard to miss if you use VS Code as the PowerShell plugin will remind you on startup:

Installation on Windows is as simple as selecting Yes and following the prompts. You’ll have to close VS Code – and for some reason, Slack, at least on Windows – and shortly you’ll see PowerShell 7 installed. I assume it’s similar on other OSes, but the specifics may differ.

When you relaunch VS Code, however, you’ll still be using whatever PowerShell you had prior. For me, it was 5.1. This is because the default integrated shell on Windows is the base PowerShell from your OS, and PowerShell 7 is a separate install.

Select Edit in settings.json and add this text (using the correct path if you installed to a non-default location) and save the file:

 "": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",

Because this is a completely different installation, it doesn’t inherit our existing profile, so before restarting, run notepad $profile and copy the contents. Now restart VS Code and you should have a PowerShell 7 prompt, if uncustomized.

Type notepad $profile, paste your old profile, save and exit, and restart VS Code. Now you have PowerShell 7 as your integrated console with the same customizations as before. Of course, with a new version there might be more you want to customize – and now you’re ready to do so!

If you run VS Code on macOS or Linux, the process above should be a good guideline, but will likely need some tweaks. If you’ve done this, please leave a comment with any specifics you can share, thanks!

7 thoughts on “Using PowerShell 7 in VS Code

  1. Thanks this works to set my VSCode terminal to lunch pwsh 7. However pwsh 7 terminal is always starting at the root of C:\ for me. Powershell 5.1 started in the project folder. Anyway to fix this?

  2. i don’t understand what to do about “run notepad $profile”. where to run it? paste what ? save it to where? sorry for these silly questions. but i am at lost.

    • Run that command in your powershell window. $profile will be the location for that version of powershell’s profile, as it changes between powershell 5, powershell ise, powershell core, etc.

  3. Click “File” > “Preferences” > “Settings” > “Users” > “Features” > “Terminal” > “External: Windows Exec”:

    Then add “C:\Program Files\PowerShell\7\pwsh.exe” instead of “C:\Windows\System32\cmd.exe”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s