Among the huge number of useful modules on the internet, there is ConvertTo-Breakpoint
by Kevin Marquette. The module is available on PowerShell Gallery and is being developed on GitHub at https://github.com/KevinMarquette/ConvertTo-Breakpoint. This module allows you to simply create breakpoints from error records, which has been a huge time-saver for us in the past.
Errors in PowerShell contains a lot of additional info, such as the target object, the category, and also the script stack trace. Kevin made use of that property to parse where in the script an issue occurred, to automatically set one or more new breakpoints. It is even possible to set breakpoints for all errors present in the stack trace. Take a look at the following code:
# Get the module if (-not (Get-Module ConvertTo-Breakpoint -List)) { Install-Module ConvertTo-Breakpoint -Scope CurrentUser -Force } # Execute the entire script and see your breakpoints appear # Execute the script a second time to...