Contact Info

Crumbtrail » Administration » Powershell » Powershell 2.0 » Set-PSBreakpoint

Set-PSBreakpoint - Powershell 2.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.


Short description
Sets a breakpoint on a line, command, or variable.

Set-PSBreakpoint -Command <string[]> [[-Script] <string[]>] [-Action <scriptblock>] [<CommonParameters>]

Set-PSBreakpoint [-Script] <string[]> [-Line] <Int32[]> [[-Column] <int>] [-Action <scriptblock>] [<CommonParameter

Set-PSBreakpoint -Variable <string[]> [[-Script] <string[]>] [-Mode {Read | Write | ReadWrite}] [-Action <scriptblo
ck>] [<CommonParameters>]

The Set-PSBreakpoint cmdlet sets a breakpoint in a script or in any command run in the current session.  You can us
e Set-PSBreakpoint to set a breakpoint before executing a script or running a command, or during debugging, when st
opped at another breakpoint.

Note: Set-PSBreakpoint cannot set a breakpoint on a remote computer. To debug a script on a remote computer, copy t
he script to the local computer and then debug it locally.

Each Set-PSBreakpoint command creates one of the following three types of breakpoints:
  -- Line breakpoint:  Sets breakpoints at particular line and column coordinates.
  -- Command breakpoint:  Sets breakpoints on commands and functions.
  -- Variable breakpoint: Sets breakpoints on variables.

You can set a breakpoint on multiple lines, commands, or variables in a single Set-PSBreakpoint command, but each S
et-PSBreakpoint command sets only one type of breakpoint. 

At a breakpoint, Windows PowerShell temporarily stops executing and gives control to the debugger. The command prom
pt changes to "DBG>", and a set of debugger commands become available for use. However, you can use the Action para
meter to specify an alternate response, such as conditions for the breakpoint or instructions to perform additional
 tasks such as logging or diagnostics.
The Set-PSBreakpoint cmdlet is one of several cmdlets designed for debugging Windows PowerShell scripts. For more i
nformation about the Windows PowerShell debugger, see about_Debuggers.