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:

 "terminal.integrated.shell.windows": "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!