Breackpoints "Stuck" in script?

I ran a debugger on a script via Windows PowerShell ISE with breakpoints.
After this, when running from PowerShell.exe (not ISE), the script hangs.
I created a minidump (using ProcExplorer) and analyzed (using windbg.exe).
Analysis shows that it is stopped at a breakpoint!
However, I have no breakpoints set in my powershell session, nor do any show up if I re-open the script in ISE.
I’ve tried restarting the server, aggressively clearing breakpoints via PS-breakpoint commands, and even deleting the file and then re-creating it from a copy I’d pasted into notepad++.

Any thoughts or advise? This seems like an ISE internals thing, or something in the way PowerShell stores breakpoints.

EXCEPTION_RECORD:  (.exr -1)
ExceptionAddress: 0000000000000000
   ExceptionCode: 80000003 (Break instruction exception)
  ExceptionFlags: 00000000
NumberParameters: 0

FAULTING_THREAD:  00002e2c

PROCESS_NAME:  powershell.exe

ERROR_CODE: (NTSTATUS) 0x80000003 - {EXCEPTION}  Breakpoint  A breakpoint has been reached.

EXCEPTION_CODE_STR:  80000003

The actual command it seems to be hanging on is this:

$Matches = $DMLFileContents | Select-String ("INSERT.*?INTO.*?DATAFIX_METADATA.*?;") -AllMatches | % { $_.Matches } | % { $_.Value }

One thought … have you tried using Visual Studio Code ??

In Powershell.exe they are only stored per session unless you create some code to pre-load breakpoints. ISE probably saves them in a file to pre-load into the console session. I do not know where they are stored on the system but should be removal from ISE

1 Like

I had not! I’ll try that and see if it reveals anything. Actually, I think even Visual Studio 2022 has powershell extensions that might tell me something. Thanks!

Thanks, neemobeer. I’ll investigate in that direction.

I noticed a warning in VSCode (Thanks for the suggestion, tonyd) because I was assigning results to $Matches, which appears to be a reserved variable that is used when you use the -match function on a string.
I rewrote the select-string to use {string} -match, and it’s working again.
Good enough is, I guess ¯_(ツ)_/¯
Thanks.