r/PowerShell • u/Aygul12345 • Jan 26 '26
Question Right setup in VS code with Powershell 7?
Im wanna start with VScode and Powershell 7 in VScode.
Are they some requirements to setup "Good to have" that I maby sleep on?
In the past I had so much trouble with "Powershell Extension"
So what are the Do's and what are the Don'ts. Help me with this.
11
Upvotes
9
u/cofonseca Jan 26 '26
There isn’t really much to set up. Install the official PowerShell extension and start writing code. What trouble have you had? It has worked fine for me for many years.
3
u/Jandalf81 Jan 26 '26
You should install the current version of PowerShell. You can get it here: https://github.com/PowerShell/PowerShell
Yes, that's the official repository.
If you want to create modules and classes I suggest setting a specific configuration setting:
Extensions -> PowerShell -> Editor Services -> Create Temporary Integrated Console -> Yes(or add"powershell.debugging.createTemporaryIntegratedConsole": trueto your settings.json). This makes it so the PowerShell session is re-started each time you run your code. When developing classes this is essential as classes are loaded exactly once in any session. Any later changes will not be reflected in a running session.Some bonus tips:
Write-HostEVERYTHING1
u/BlackV Jan 26 '26
Turn of state/session restore ( can't remember the exact name sorry)
1
u/Dazzling_Pay_3393 Jan 28 '26
I use the powershell extension extensively. I've not really come across anyone using anything else.
I've had some difficulty getting it to play nicely with vscode. May or may not be relevant to you.
I was on windows, so it came with 5.1.
Installed vscode and the powershell extension which gives you the "Integrated Terminal" which I want.
Looking at psversion table variable in the integrated terminal would show 5.1.
I now install powershell 7/core/pwsh
The psversiontable variable of the integrated terminal still shows 5.1. <-- problem
To fix this, in vscode settings there's a setting something similar to "additional powershell executable path"
Populate that with the path to pwsh.
Then if I recall you can set the default terminal/shell/powershell profile that the extension uses, i.e. the one we just created pointing to pwsh.
May need to restart the extension or maybe just be safe and restart vscode for the changes to take affect.
Do use the auto format feature of the extension all the time.
Don't expect your apps / scripts to be very fast.
Do look at the pester powershell testing module
Don't make too many powershell 'jobs' as each is a whole new process and you can crash the host :)
Do use breakpoints instead or as well as using console output for debugging.
Don't get over zealous with your use of $erroractionpreference = 'silentlycontinue'
1
u/ImissHurley Jan 31 '26
any suggestions on how to get variables to show correctly in VS Code?
When I first started using PowerShell, I used PowerGUI as an editor and I got very spoiled to how it showed all of the variables very clearly.
https://i.imgur.com/I20ZMM0.png