Quickly Set breakpoints on each and every line of PowerShell Script
Suppose, You’re working on a not-so-small PowerShell Script with more than 300–400 lines of code which is quite common in an environment where PowerShell is used for Automation (PowerShell is undeniably a great way of Windows Automation), and you’re stuck at a point where you can’t just figure out what the script is really doing or what is its flow. You would probably go with the debugger option in PowerShell ISE and would set some breakpoints.
But, what if you want to set breakpoint on each and every line of your script to abolish the slightest of the doubt. How would you do that? Use a cmdlet called Set-PSBreakpoint and a for-loop.
How to?
- Open a new .ps1 script file in PowerShell ISE
- Copy-past this script there and provide path to your ps1 file.
- Run it and it should look like this
- Check back the original script file and notice the breakpoints.
- Now, while you run the script, you can use F9 function key to quickly parse through all the breakpoints.
- You can quickly remove all those breakpoints directly using Ctrl+Shift+F9
That’s it in this post. I hope you find it easy to implement. Feel free to share. See you.