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!
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?
I didn’t know how to do this, but per https://stackoverflow.com/questions/32069265/how-do-you-set-powershells-default-directory it looks like you add something like “Set-Location C:\my\default\working\directory” to your profile(s). You can also modify the working directory in the startup shortcut but I suspect that doesn’t work for VS Code.
thanks for this. It worked perfectly
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.
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”