Description
Prerequisites
- I have written a descriptive issue title.I have searched all open and closed issues to ensure it has not already been reported.I have read the troubleshooting guide.I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.If this is a security issue, I have read the security issue reporting guidance.
Summary
I can't get the debugger to work. Sometimes it will, sometimes it won't. The code just runs ignoring break points. I tried to follow the instructions in https://devblogs.microsoft.com/scripting/debugging-powershell-script-in-visual-studio-code-part-1/#comments but they aren't even right. They no longer describe the user interface. So, I don't know what to do. I got the "Powershell Launch Current File" into the drop down on the RUN AND DEBUG window. It seems like that worked once, but then I stopped the run part way through the script and the terminal hung on the DBG prompt. So, I closed that terminal. It popped up a message saying that it needed to be running; so, I started it again. But now, no breaking. Did I do it right, but this Powershell extension just really is broken or what?
PowerShell Version
Name Value
---- -----
PSVersion 5.1.17763.2931
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.2931
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Visual Studio Code Version
1.73.1
6261075646f055b99068d3688932416f2346dd3b
x64
Extension Version
code --list-extensions --show-versions | Select-String powershell
Steps to Reproduce
open file.
set breakpoint.
type command into the terminal window and hit enter.
Visuals
No response
Logs
No response
Activity
andyleejordan commentedon Nov 22, 2022
Can you try PowerShell 7? The PowerShell 5.1 support is best effort, and debugging is where it gets seriously janky (it doesn't have the debugger APIs that we use to support proper debugging like we do with PowerShell 7).
Rom265 commentedon Nov 24, 2022
Thanks for replying, but no sadly it looks like I'll have to give up on VS Code again and go back to Powershell ISE as my only real choice for using Powershell.
TheMasterPrawn commentedon Nov 24, 2022
I have the same problem. Until PowerShell cmdlets for Azure etc support functionality that was available I am still expected to maintain code for customers in older versions of PowerShell. After moving the team to VSCODE its a massive step backwards as it took me months to get people off ISE. The latest is "Exception encountered starting EditorServices. Exception logged in D:\a_work\1\s\src\PowerShellEditorServices.Hosting\Commands\StartEditorServicesCommand.cs on line 238 in EndProcessing:"
Completely dead in the water on this
This looks like its related to some update in the ps add on
ninmonkey commentedon Nov 26, 2022
If there's an error, restarting the term usually resolves that.

Without logs, there's a bunch of different things that could have happened, we can't know what. It's not necessarily the debugger.
Re-Attach Debugger
if the debugger isn't attaching when you're running
DoStuff
placewait-debugger
wait-debugger
When addons update, sometimes they require a reload. Until you reload, it definitely can break things. But that's not pwsh specific.
Rom265 commentedon Dec 1, 2022
I figured it out. The problem stems from the fact that I have used Powershell a lot. This program is NOTHING LIKE Powershell ISE which I am used to. Actually, the problem is that this program is not made for Powershell and that will always be a problem. In some ways it will always be harder to use. Certainly harder to get started with. So, I expected that when I run a command from the terminal prompt, it will run. It does and that fools you because, to engage the debugger, you can ONLY USE F5 (or the icon). This means that you must create a temporary file somewhere, open it in VS Code, write the command line you need and then hit F5 there. Voila, it stops at the break point. Yes, this is very kludgy, one of the several ways Powershell presumably does not match the languages VS Code was created for.
andyleejordan commentedon Dec 1, 2022
If you put a
Wait-Debugger
in the command / script-block you're running, that should start up and attach the VS Code debugger too (if it doesn't, let me know, I worked real hard to wire that up)! You should also check out the "Interactive Session" supplied default debug configuration.andyleejordan commentedon Dec 1, 2022
Also,
You really hit the nail on the head about how difficult the development and maintenance of this extension is 😅
andyleejordan commentedon Dec 1, 2022
We also have some work-in-progress to sync PowerShell breakpoints set via
Set-PSBreakpoint
etc. with the VS Code debugger: #4065 no ETA though.Rom265 commentedon Dec 4, 2022
Ah! You're a genius. ha ha I put
wait-debugger;
at the head of my command and then after running the command, I had to hit F5 a couple times to get past a tab that opened up called [this computer] Script Listing.ps1. And then it worked and stopped at the set break point. I haven't tried any complex breakpoints like a conditional breakpoint.andyleejordan commentedon Dec 5, 2022
Heck yeah! I'm glad to hear it. I definitely want you to be able to use (and enjoy using!) the extension, please let me know if you run into other issues.