

In the Console pane, we will get information that execution Hit Line breakpoint with starting next line meaning that we are in debugging mode right now. In Script pane all the open tabs will have next to the name of the script. It pauses execution there and highlights the line on which it paused. The script will run until it encountered the first breakpoint.

Go to the Debug menu and click Run/Continue.Click on Run Script icon on the toolbar.There are several ways to start debugging: REMEMBER: Even before starting debugging your script, save it first, then set one or more breakpoints and you are ready to start debugging.
#Script debugger add clippings how to#
#Script debugger add clippings zip file#
Please feel free to download the zip file with source code so you can follow along. This project is a library of many awesome CmdLets that help us IT experts to be more efficient in our daily IT tasks. PowerShell Debugging Exampleįor this example, I will use my own CmdLets Get-CPUInfo and Get-ComputerInfo and they are part of the Efficiency Booster PowerShell Project. Basically F9 is to turn on and off breakpoint on the line where is cursor or mouse point. If we want to remove breakpoint click on that line of code and press F9.This will be executed without debugging line by line and we can move one with debugging in the current function. If we want to avoid debugging in function or script calls we can press F10 – Step over and we will not enter into function or script in debugging mode.If the current statement is a function or a script call, then the debugger steps into that function or script, and we can continue debugging in that function. We can continue line by line by pressing F11 – Step Into.Run the code by pressing F5 or make a call to the script and the code will run as usual until it reaches breakpoint that will switch to debugging mode and we can go through the code to debug it.Now you want to set one or more breakpoints by selecting the line of code where you want to place the breakpoint and then right-click mouse and click on “Toggle Breakpoint” or press F9 or go to menu Debug and click on “Toggle Breakpoint”.An unsaved script cannot set breakpoints. In order to set breakpoints in the script that you want to debug you need to save it first.To debug PowerShell script follow these easy steps: Here is a short table of the most important keyboard shortcuts while debugging.Ĭommand Keyboard Shortcut Console Pane Shortcut Toggle Breakpoint F9 Run/Continue F5 Type C and then press ENTER to continue debugging Step Into F11 Type S and then press ENTER to continue debugging Step Over F10 Type V and then press ENTER to continue debugging Step Out Shift + F11 Type O and then press ENTER to continue debugging Stop Debugger Shift + F5 Type Q and then press ENTER to continue debugging Remove All Breakpoints Ctrl + Shift + F9 List Breakpoints Ctrl + Shift + L Display Call Stack Ctrl + Shift + D Type K and then press ENTER to continue debugging Break All Ctrl + B Go to Console Pane Ctrl + D Go to Script Pane Ctrl + I Table 1 - Debugging keyboard shortcuts How To Debug PowerShell Scripts While you are debugging the code the fastest way to navigate is by using the keyboard shortcuts so it is very important to know them. NOTE: If you want to learn more about Error Handling please read How To Log PowerShell Errors And Much More Useful Keyboard Shortcuts to see how code runs and understand it better, especially if you are not the one who wrote it in the first place.to troubleshoot the errors and to help determine the cause of an error.There are several reasons why would programmer decide to do debugging of code and here are few: Useful PowerShell Debugging Articles Why Would You Debug The Code?.

