Using the ISE Debugger

by Apr 5, 2013

ISE has a simple yet effective debugger built-in that you can use to step through your code. The debugger does require that you save your script first. Unsaved scripts cannot be debugged.

To start, add breakpoints to your script by selecting the lines where you want PowerShell to stop, then press F9. Breakpoint lines are marked red. Next, run the script, for example by pressing F5.

The script runs, and PowerShell halts execution when the code hits the first breakpoint. You can now use the interactive console to examine (and change) variables, hover over variables in your script code to examine the current content, press CTRL+SHIFT+D to view the current call stack (which shows nested relationships) or press CTRL+SHIFT+L to list all breakpoints. Get-Variable dumps all variables.

To step through your code, either press F10 (which steps inside your own code only) or F11 (which works like "micro"-stepping and steps through error handlers and nested functions as you call them).

To resume regular execution, press F5. And to cancel debugging and stopping execution, press SHIFT+F5. CTRL+SHIFT+F9 removes all breakpoints.

If you can't remember all these keyboard shortcuts, open the Debug menu. It lists all the available debug commands plus their keyboard shortcuts.

Twitter This Tip! ReTweet this Tip!