O'Reilly logo

PowerShell Troubleshooting Guide by Michael Shepard

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Debugging in the console

The Set-PSDebug cmdlet gives a good amount of detail, but getting to a particular point in the code requires you to add Set-PSDebug statements in the code (which you might not be able to do) or step through all of the code up until that point. Fortunately, there is another set of cmdlets that allows interactive debugging, the PSBreakPoint cmdlets:

  • Set-PSBreakPoint
  • Remove-PSBreakPoint
  • Get-PSBreakPoint
  • Enable-PSBreakPoint
  • Disable-PSBreakPoint

With Set-PSBreakpoint, it is easy to create a breakpoint to cause the execution to be suspended when a certain line is reached using the –Line parameter. One caveat is that the parameter sets including the –Line parameter, also include a mandatory script parameter that refers to a file on ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required