You can set three types of breakpoints in the Windows PowerShell debugging environment: variable breakpoints, command breakpoints, and line breakpoints. Of these, in the Windows PowerShell ISE debugging environment, only line breakpoints highlighted and can be set by using the menu or the keyboard shortcuts. The other two types of breakpoints can still be set, but they are set from the command pane by using the Set-PSBreakpoint cmdlet. You can remove, enable, disable, and list all breakpoints. This section describes how you can perform debugging tasks in Windows PowerShell ISE by using the menus where available, and perform a wider range of commands from the Command Pane by using scripting.

Managing Breakpoints

Set a Breakpoint

Sets a line breakpoint in a Windows PowerShell script or function. A breakpoint can be set in a script only after it has been saved.

Right-click the line where you want to set a breakpoint, and then click Toggle Breakpoint. Or, click the line where you want to set a breakpoint, and on the Debug menu, click Toggle Breakpoint. The following script is an example of how you can set a variable breakpoint from the Command Pane by using the Set-PSBreakpoint cmdlet.

# This command sets a breakpoint on the Server variable in the Sample.ps1 script.
set-psbreakpoint -script sample.ps1 -variable Server 

List All Breakpoints

Displays all breakpoints in the current session.

On the Debug menu, click List Breakpoints. The following script is an example of how you can list all breakpoints from the Command Pane by using the Get-PSBreakpoint cmdlet.

 # This command lists all breakpoints in the current session. 
get-psbreakpoint 

Remove a Breakpoint

Deletes a specific line breakpoint.

Right-click the line where you want to remove a breakpoint, and then click Toggle Breakpoint. Or, click the line where you want to remove a breakpoint, and on the Debug menu, click Toggle Breakpoint. The following script is an example of how to remove a breakpoint with a specified ID from the Command Pane by using the Remove-PSBreakpoint cmdlet.

# This command deletes the breakpoint with breakpoint ID 2.
remove-psbreakpoint -id 2

Remove All Breakpoints

Deletes all breakpoints from the current session.

On the Debug menu, click Remove All Breakpoints. The following script is an example of how to remove all breakpoints from the Command Pane by using the Remove-PSBreakpoint cmdlet.

# This command deletes all of the breakpoints in the current session.
get-breakpoint | remove-breakpoint


Disable a Breakpoint

Disables a specific line breakpoint.

Right-click the line where you want to disable a breakpoint, and then click Disable Breakpoint. Or, click the line where you want to disable a breakpoint, and on the Debug menu, click Disable Breakpoint. The following script is an example of how you can remove a breakpoint with a specified ID from the Command Pane by using the Disable-PSBreakpoint cmdlet.

# This command disables the breakpoint with breakpoint ID 0.
disable-psbreakpoint -id 0


Disable All Breakpoints

Disables all breakpoints in the current session.

On the Debug menu, click Disable all Breakpoints. The following script is an example of how you can disable all breakpoints from the Command Pane by using the Disable-PSBreakpoint cmdlet.

# This command disables all breakpoints in the current console. 
# You can abbreviate this command as: "gbp | dbp".

get-psbreakpoint | disable-psbreakpoint




Enable a Breakpoint

Enables a specific line breakpoint.

Right-click the line where you want to enable a breakpoint, and then click Enable Breakpoint. Or, click the line where you want to enable a breakpoint, and then press F8 or, on the Debug menu, click Enable Breakpoint. The following script is an example of how you can enable specific breakpoints from the Command Pane by using the Enable-PSBreakpoint cmdlet.

# This command enables breakpoints with breakpoint IDs 0, 1, and 5.
enable-psbreakpoint -id 0, 1, 5




Enable All Breakpoints

Enables all breakpoints in the current session.

On the Debug menu, click Enable all Breakpoints. is the following script is an example of how you can enable all breakpoints from the Command Pane by using the Enable-PSBreakpoint cmdlet.

# This command enables all breakpoints in the current session. 
# You can abbreviate the command as "gbp | ebp".


get-psbreakpoint | enable-psbreakpoint

See Also




Table Of Contents