Category Archives: PSBreakpoint

Set-PSBreakpoint

NAME
    Set-PSBreakpoint

SYNOPSIS
    Sets a breakpoint on a line, command, or Variable.

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

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

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

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

    Note: Set-PSBreakpoint cannot set a breakpoint on a remote computer. To debug a script on a remote computer, copy the 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 Set-PSBreakpoint command sets only one type of breakpoint.

    At a breakpoint, Windows PowerShell temporarily stops executing and gives control to the debugger. The command prompt changes to “DBG>”, and a set of debugger commands become available for use. However, you can use the Action parameter 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 information about the Windows PowerShell debugger, see about_debuggers.

PARAMETERS
    -Action <scriptblock>
        Specifies commands that run at each breakpoint instead of breaking. Enter a script block that contains the commands. You can use this parameter to set conditional breakpoints or to perform other tasks, such as testing or logging.

        If this parameter is omitted, or no action is specified, execution stops at the breakpoint, and the debugger starts.

        When the Action parameter is used, the Action script block runs at each breakpoint. Execution does not stop unless the script block includes the Break keyword. If you use the Continue keyword in the script block, execution resumes until the next breakpoint.

        For more information, see about_script_blocks, about_Break, and about_Continue.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Column <int>
        Specifies the column number of the column in the script file on which execution stops. Enter only one column number. The default is column 1.

        The Column value is used with the value of the Line parameter to specify the breakpoint. If the Line parameter specifies multiple lines, the Column parameter sets a breakpoint at the specified column on each of the specified lines. Windows PowerShell stops executing before the statement or expression that includes the character at the specified line and column position.

        Columns are counted from the top left margin beginning with column number 1 (not 0). If you specify a column that does not exist in the script, an error is not declared, but the breakpoint is never executed.

        Required?                    false
        Position?                    3
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Command <string[]>
        Sets a command breakpoint. Enter command names, such as “Get-Process” or Function names. Wildcards are permitted.

        Execution stops just before each instance of each command is executed. If the command is a Function, execution stops each time the Function is called and at each BEGIN, PROCESS, and END section.

        Required?                    true
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? true

    -Line <Int32[]>
        Sets a line breakpoint in a script. Enter one or more line numbers, separated by commas. Windows PowerShell stops immediately before executing the statement that begins on each of the specified lines.

        Lines are counted from the top left margin of the script file beginning with line number 1 (not 0). If you specify a blank line, execution stops before the next non-blank line. If the line is out of range, the breakpoint is never hit.

        Required?                    true
        Position?                    2
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Mode <VariableAccessMode>
        Determines the mode of access that triggers Variable breakpoints. The default is Write.

        This parameter is valid only when the Variable parameter is used in the command. The mode applies to all breakpoints set in the command.

        Valid values are:

        — Write: Stops execution immediately before a new value is written to the Variable.

        — Read: Stops execution when the Variable is read, that is, when its value is accessed, either to be assigned, displayed, or used. In read mode, execution does not stop when the value of the Variable changes.

        — ReadWrite: Stops execution when the Variable is read or written.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Script <string[]>
        Sets a breakpoint in each of the specified script files. Enter the paths and file names of one or more script files. If the files are in the current directory, you can omit the path. Wildcards are permitted.

        By default, Variable breakpoints and command breakpoints are set on any command that runs in the current session. This parameter is required only when setting a line breakpoint.

        Required?                    false
        Position?                    1
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? true

    -Variable <string[]>
        Sets a Variable breakpoint. Enter a comma-separated list of Variables without dollar signs ($).

        Use the Mode parameters to determine the mode of access that triggers the breakpoints. The default mode, Write, stops execution just before a new value is written to the Variable.

        Required?                    true
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    None
        You cannot pipe input to Set-PSBreakpoint.

OUTPUTS
    Breakpoint object (System.Management.Automation.LineBreakpoint, System.Management.Automation.VariableBreakpoint, System.Management.Automation.CommandBreakpoint)
        Set-PSBreakpoint returns an object that represents each breakpoint that it sets.

NOTES

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

        When you set a breakpoint on more than one line, command, or Variable, Set-PSBreakpoint generates a breakpoint object for each entry.

        When setting a breakpoint on a Function or Variable at the command prompt, you can set the breakpoint before or after you create the Function or Variable.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Set-PSBreakpoint -Script sample.ps1 -Line 5

    Column     : 0
    Line     : 5
    Action     :
    Enabled    : True
    HitCount : 0
    Id         : 0
    Script     : C:\ps-test\sample.ps1
    ScriptName : C:\ps-test\sample.ps1

    Description
    ———–
    This command sets a breakpoint at line 5 in the Sample.ps1 script. As a result, when the script runs, execution stops immediately before line 5 would execute.

    When you set a new breakpoint by line number, the Set-PSBreakpoint cmdlet generates a line breakpoint object (System.Management.Automation.LineBreakpoint) that includes the breakpoint ID and hit count, as shown in the following sample output.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Set-PSBreakpoint -command Increment -Script sample.ps1

    Command    : Increment
    Action     :
    Enabled    : True
    HitCount : 0
    Id         : 1
    Script     : C:\ps-test\sample.ps1
    ScriptName : C:\ps-test\sample.ps1

    Description
    ———–
    This command creates a command breakpoint on the Increment Function in the Sample.ps1 cmdlet. The script stops executing immediately before each call to the specified Function.

    The result is a command breakpoint object. Before the script runs, the value of the HitCount property is 0.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Set-PSBreakpoint -Script sample.ps1 -variable Server -Mode ReadWrite

    Description
    ———–
    This command sets a breakpoint on the Server Variable in the Sample.ps1 script. It uses the Mode parameter with a value of ReadWrite to stop execution when the value of the Variable is read and just before the value changes.

    ————————– EXAMPLE 4 ————————–

    C:\PS>Set-PSBreakpoint -Script Sample.ps1 -command “write*”

    Description
    ———–
    This command sets a breakpoint on every command in the Sample.ps1 script that begins with “write”, such as “Write-Host“.

    ————————– EXAMPLE 5 ————————–

    C:\PS>Set-PSBreakpoint -Script test.ps1 -command DiskTest `
     -Action { (if $disk -gt 2) { break } }

    Description
    ———–
    This command stops execution at the DiskTest Function in the Test.ps1 script only when the value of the $disk Variable is greater than 2.

    It uses the Set-PSBreakpoint cmdlet to set a command breakpoint on the DiskTest Function. The value of the action is a script block that tests the value of the $disk Variable in the Function.

    The action uses the BREAK keyword to stop execution if the condition is met. The alternative (and the default) is CONTINUE.

    ————————– EXAMPLE 6 ————————–

    C:\PS>Set-PSBreakpoint -command Checkpoint-Computer

    Id     : 0
    Command : Checkpoint-Computer
    Enabled : True
    HitCount : 0
    Action :

    C:\PS> Function CheckLog {
    >> Get-Eventlog -log Application |
    >> where {($_.source -like “TestApp”) -and ($_.Message -like “*failed*”)}
    >>}
    >>
    C:\PS> Checklog
    DEBUG: Hit breakpoint(s)
    DEBUG: Function breakpoint on ‘prompt:Checklog’
    C:\PS>>>

    Description
    ———–
    This command sets a breakpoint on the CheckLog Function. Because the command does not specify a script, the breakpoint is set on anything that runs in the current session. The debugger breaks when the Function is called, not when it is declared.

    ————————– EXAMPLE 7 ————————–

    C:\PS>Set-PSBreakpoint -Script sample.ps1 -Line 1, 14, 19 -Column 2 -Action {&(log.ps1)}

    Column     : 2
    Line     : 1
    Action     :
    Enabled    : True
    HitCount : 0
    Id         : 6
    Script     : C:\ps-test\sample.ps1
    ScriptName : C:\ps-test\sample.ps1

    Column     : 2
    Line     : 14
    Action     :
    Enabled    : True
    HitCount : 0
    Id         : 7
    Script     : C:\ps-test\sample.ps1
    ScriptName : C:\ps-test\sample.ps1

    Column     : 2
    Line     : 19
    Action     :
    Enabled    : True
    HitCount : 0
    Id         : 8
    Script     : C:\ps-test\sample.ps1
    ScriptName : C:\ps-test\sample.ps1

    Description
    ———–
    This command sets three line breakpoints in the Sample.ps1 script. It sets one breakpoint at column 2 on each of the lines specified in the script. The action specified in the Action parameter applies to all breakpoints.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113449
    about_debuggers
    Get-PSBreakpoint
    Enable-PSBreakpoint
    Disable-PSBreakpoint
    Remove-PSBreakpoint
    Get-PSCallStack

Remove-PSBreakpoint

NAME
    Remove-PSBreakpoint

SYNOPSIS
    Deletes breakpoints from the current console.

SYNTAX
    Remove-PSBreakpoint [-Id] <Int32[]> [-Confirm] [-WhatIf] [<CommonParameters>]

    Remove-PSBreakpoint [-Breakpoint] <Breakpoint[]> [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Remove-PSBreakpoint cmdlet deletes a breakpoint. Enter a breakpoint object or a breakpoint ID.

    When you remove a breakpoint, the breakpoint object is no longer available or Functional. If you have saved a breakpoint object in a Variable, the reference still exists, but the breakpoint does not Function.

    Remove-PSBreakpoint is one of several cmdlets designed for debugging Windows PowerShell scripts. For more information about the Windows PowerShell debugger, see about_debuggers.

PARAMETERS
    -Breakpoint <Breakpoint[]>
        Specifies the breakpoints to delete. Enter a Variable that contains breakpoint objects or a command that gets breakpoint objects, such as a Get-PSBreakpoint command. You can also pipe breakpoint objects to Remove-PSBreakpoint.

        Required?                    true
        Position?                    1
        Default value                None
        Accept pipeline input?     true (ByValue)
        Accept wildcard characters? false

    -Id <Int32[]>
        Deletes breakpoints with the specified breakpoint IDs.

        Required?                    true
        Position?                    1
        Default value                None
        Accept pipeline input?     true (ByPropertyName)
        Accept wildcard characters? false

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -WhatIf [<SwitchParameter>]
        Describes what would happen if you executed the command without actually executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.Management.Automation.Breakpoint
        You can pipe breakpoint objects to Remove-PSBreakpoint.

OUTPUTS
    None
        The cmdlet does not generate any output.

NOTES

    ————————– EXAMPLE 1 ————————–

    C:\PS>get-Breakpoint | remove-Breakpoint

    Description
    ———–
    This command deletes all of the breakpoints in the current console.

    ————————– EXAMPLE 2 ————————–

    C:\PS>$b = Set-PSBreakpoint -script sample.ps1 -variable Name

    C:\PS> $b | Remove-PSBreakpoint

    Description
    ———–
    This command deletes a breakpoint.

    The first command uses the Set-PSBreakpoint cmdlet to create a breakpoint on the Name Variable in the Sample.ps1 script. Then, it saves the breakpoint object in the $b Variable.

    The second command uses the Remove-PSBreakpoint cmdlet to delete the new breakpoint. It uses a pipeline operator (|) to send the breakpoint object in the $b Variable to the Remove-PSBreakpoint cmdlet.

    As a result of this command, if you run the script, it runs to completion without stopping. Also, the Get-PSBreakpoint cmdlet does not return this breakpoint.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Remove-PSBreakpoint -id 2

    Description
    ———–
    This command deletes the breakpoint with breakpoint ID 2.

    ————————– EXAMPLE 4 ————————–

    C:\PS>function del-psb { Get-PSBreakpoint | Remove-PSBreakpoint }

    Description
    ———–
    This simple Function deletes all of the breakpoints in the current console. It uses the Get-PSBreakpoint cmdlet to get the breakpoints. Then, it uses a pipeline operator (|) to send the breakpoints to the Remove-PSBreakpoint cmdlet, which deletes them.

    As a result, you can type “del-psb” instead of the longer command.

    To save the Function, add it to your Windows PowerShell profile.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113375
    about_debuggers
    Set-PSBreakpoint
    Get-PSBreakpoint
    Enable-PSBreakpoint
    Disable-PSBreakpoint
    Get-PSCallStack

Get-PSBreakpoint

NAME
    Get-PSBreakpoint

SYNOPSIS
    Gets the breakpoints that are set in the current session.

SYNTAX
    Get-PSBreakpoint [[-Script] <string[]>] [<CommonParameters>]

    Get-PSBreakpoint -Command <string[]> [-Script <string[]>] [<CommonParameters>]

    Get-PSBreakpoint [-Id] <Int32[]> [<CommonParameters>]

    Get-PSBreakpoint [-Type] <BreakpointType[]> [-Script <string[]>] [<CommonParameters>]

    Get-PSBreakpoint -Variable <string[]> [-Script <string[]>] [<CommonParameters>]

DESCRIPTION
    The Get-PSBreakpoint cmdlet gets the breakpoints that are set in the current session. You can use the cmdlet parameters to get particular breakpoints.

    A breakpoint is a point in a command or script where execution stops temporarily so that you can examine the instructions. Get-PSBreakpoint is one of several cmdlets designed for debugging Windows PowerShell scripts and commands. For more information about the Windows PowerShell debugger, see about_debuggers.

PARAMETERS
    -Command <string[]>
        Gets command breakpoints that are set on the specified command names. Enter the command names, such as the name of a cmdlet or Function.

        Required?                    true
        Position?                    named
        Default value                All breakpoints
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Id <Int32[]>
        Gets the breakpoints with the specified breakpoint IDs. Enter the IDs in a comma-separated list. You can also pipe breakpoint IDs to Get-PSBreakpoint.

        Required?                    true
        Position?                    1
        Default value                All breakpoints
        Accept pipeline input?     true (ByValue)
        Accept wildcard characters? false

    -Script <string[]>
        Gets only the breakpoints in the specified scripts. Enter the path (optional) and names of one or more script files. The default location is the current directory.

        Required?                    false
        Position?                    named
        Default value                All breakpoints
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Type <BreakpointType[]>
        Gets only breakpoints of the specified types. Enter one or more types. Valid values are Line, Command, and Variable. You can also pipe breakpoint types to Get-PSBreakpoint.

        Required?                    true
        Position?                    1
        Default value                All breakpoints
        Accept pipeline input?     true (ByValue)
        Accept wildcard characters? false

    -Variable <string[]>
        Gets Variable breakpoints that are set on the specified Variable names. Enter the Variable names without dollar signs.

        Required?                    true
        Position?                    named
        Default value                All breakpoints
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.Int32, Microsoft.PowerShell.Commands.BreakpointType
        You can pipe breakpoint IDs and breakpoint types to Get-PSBreakpoint.

OUTPUTS
    Breakpoint object (System.Management.Automation.LineBreakpoint, System.Management.Automation.VariableBreakpoint, System.Management.Automation.CommandBreakpoint)
        Get-PSBreakpoint returns objects that represent the breakpoints in the session.

NOTES

        You can use Get-PSBreakpoint or its Alias, “gbp”.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Get-PSBreakpoint

    Description
    ———–
    This command gets all breakpoints set on all scripts and Functions in the current session.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Get-PSBreakpoint -Id 2

    Function : Increment
    Action     :
    Enabled    : True
    HitCount : 0
    Id         : 2
    Script     : C:\ps-test\sample.ps1
    ScriptName : C:\ps-test\sample.ps1

    Description
    ———–
    This command gets the breakpoint with breakpoint ID 2.

    ————————– EXAMPLE 3 ————————–

    C:\PS>$b = Set-PSBreakpoint -Script sample.ps1 -function increment

    C:\PS> $b.Id | Get-PSBreakpoint

    Description
    ———–
    These commands show how to get a breakpoint by piping a breakpoint ID to Get-PSBreakpoint.

    The first command uses the Set-PSBreakpoint cmdlet to create a breakpoint on the Increment Function in the Sample.ps1 script. It saves the breakpoint object in the $b Variable.

    The second command uses the dot operator (.) to get the Id property of the breakpoint object in the $b Variable. It uses a pipeline operator (|) to send the ID to the Get-PSBreakpoint cmdlet.

    As a result, Get-PSBreakpoint gets the breakpoint with the specified ID.

    ————————– EXAMPLE 4 ————————–

    C:\PS>Get-PSBreakpoint -Script Sample.ps1, SupportScript.ps1

    Description
    ———–
    This command gets all of the breakpoints in the Sample.ps1 and SupportScript.ps1 files.

    This command does not get other breakpointS that might be set in other scripts or on Functions in the session.

    ————————– EXAMPLE 5 ————————–

    C:\PS>Get-PSBreakpoint -command Read-Host, Write-Host -Script Sample.ps1

    Description
    ———–
    This command gets all Command breakpoints that are set on Read-Host or Write-Host commands in the Sample.ps1 file.

    ————————– EXAMPLE 6 ————————–

    C:\PS>Get-PSBreakpoint -type Command -Script Sample.ps1

    Description
    ———–
    This command gets all Command breakpoints in the Sample.ps1 file.

    ————————– EXAMPLE 7 ————————–

    C:\PS>Get-PSBreakpoint -variable Index, Swap

    Description
    ———–
    This command gets breakpoints that are set on the $index and $swap Variables in the current session.

    ————————– EXAMPLE 8 ————————–

    C:\PS>Get-PSBreakpoint -type line, Variable -Script Sample.ps1

    Description
    ———–
    This command gets all line and Variable breakpoints in the Sample.ps1 script.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113325
    about_debuggers
    Set-PSBreakpoint
    Disable-PSBreakpoint
    Enable-PSBreakpoint
    Remove-PSBreakpoint
    Get-PSCallStack

Enable-PSBreakpoint

NAME
    Enable-PSBreakpoint

SYNOPSIS
    Enables the breakpoints in the current console.

SYNTAX
    Enable-PSBreakpoint [-Id] <Int32[]> [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

    Enable-PSBreakpoint [-Breakpoint] <Breakpoint[]> [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Enable-PSBreakpoint cmdlet re-enables disabled breakpoints. You can use it to enable all breakpoints, or you can specify breakpoints by submitting breakpoint objects or breakpoint IDs.

    A breakpoint is a point in a script where execution stops temporarily so that you can examine the instructions in the script. Newly created breakpoints are automatically enabled, but you can disable them by using the Disable-PSBreakpoint cmdlet.

    Technically, this cmdlet changes the value of the Enabled property of a breakpoint object to True.

    Enable-PSBreakpoint is one of several cmdlets designed for debugging Windows PowerShell scripts. For more information about the Windows PowerShell debugger, see about_debuggers.

PARAMETERS
    -Breakpoint <Breakpoint[]>
        Specifies the breakpoints to enable. Enter a Variable that contains breakpoint objects or a command that gets breakpoint objects, such as a Get-PSBreakpoint command. You can also pipe breakpoint objects to Enable-PSBreakpoint.

        Required?                    true
        Position?                    1
        Default value                None.
        Accept pipeline input?     true (ByValue)
        Accept wildcard characters? false

    -Id <Int32[]>
        Enables breakpoints that have the specified breakpoint IDs. The default value is all breakpoints. Enter the IDs or a Variable that contains the IDs. (You cannot pipe IDs to Enable-PSBreakpoint.) To find the ID of a breakpoint, use the Get-PSBreakpoint cmdlet.

        Required?                    true
        Position?                    1
        Default value                None
        Accept pipeline input?     true (ByPropertyName)
        Accept wildcard characters? false

    -PassThru [<SwitchParameter>]
        Returns an object representing the enabled breakpoint. By default, this cmdlet does not generate any output.

        Required?                    false
        Position?                    named
        Default value                No output
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -WhatIf [<SwitchParameter>]
        Describes what would happen if you executed the command without actually executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.Management.Automation.Breakpoint
        You can pipe a breakpoint object to Enable-PSBreakpoint.

OUTPUTS
    None or System.Management.Automation.Breakpoint
        When you use the PassThru parameter, Enable-PSBreakpoint returns a breakpoint object that represent that breakpoint that was enabled. Otherwise, this cmdlet does not generate any output.

NOTES

        The Enable-PSBreakpoint cmdlet does not generate an error if you try to enable a breakpoint that is already enabled. As such, you can enable all breakpoints without error, even when only a few are disabled.

        Breakpoints are enabled when you create them by using the Set-PSBreakpoint cmdlet. You do not need to enable newly created breakpoints.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Get-PSBreakpoint | Enable-PSBreakpoint

    Description
    ———–
    This command enables all breakpoints in the current console. You can abbreviate the command as “gbp | ebp”.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Enable-PSBreakpoint -Id 0, 1, 5

    Description
    ———–
    This command enables breakpoints with breakpoint IDs 0, 1, and 5.

    ————————– EXAMPLE 3 ————————–

    C:\PS>$b = Set-PSBreakpoint -script sample.ps1 -variable Name

    C:\PS> $b | Disable-PSBreakpoint -PassThru

    AccessMode : Write
    Variable : Name
    Action     :
    Enabled    : False
    HitCount : 0
    Id         : 0
    Script     : C:\ps-test\sample.ps1
    ScriptName : C:\ps-test\sample.ps1

    C:\PS> $b | Enable-PSBreakpoint -PassThru

    AccessMode : Write
    Variable : Name
    Action     :
    Enabled    : True
    HitCount : 0
    Id         : 0
    Script     : C:\ps-test\sample.ps1
    ScriptName : C:\ps-test\sample.ps1

    Description
    ———–
    These commands re-enable a breakpoint that has been disabled.

    The first command uses the Set-PSBreakpoint cmdlet to create a breakpoint on the “Name” Variable in the Sample.ps1 script. Then, it saves the breakpoint object in the $b Variable.

    The second command uses the Disable-PSBreakpoint cmdlet to disable the new breakpoint. It uses a pipeline operator (|) to send the breakpoint object in $b to the Disable-PSBreakpoint cmdlet, and it uses the PassThru parameter of Disable-PSBreakpoint to display the disabled breakpoint object. This lets you verify that the value of the Enabled property of the breakpoint object is False.

    The third command uses the Enable-PSBreakpoint cmdlet to re-enable the breakpoint. It uses a pipeline operator (|) to send the breakpoint object in $b to the Enable-PSBreakpoint cmdlet, and it uses the PassThru parameter of Enable-PSBreakpoint to display the breakpoint object. This lets you verify that the value of the Enabled property of the breakpoint object is True.

    The results are shown in the following sample output.

    ————————– EXAMPLE 4 ————————–

    C:\PS>$b = Get-PSBreakpoint -Id 3, 5

    C:\PS> Enable-PSBreakpoint -breakpoint $b

    Description
    ———–
    These commands enable a set of breakpoints by specifying their breakpoint objects.

    The first command uses the Get-PSBreakpoint cmdlet to get the breakpoints and saves them in the $b Variable.

    The second command uses the Enable-PSBreakpoint cmdlet and its Breakpoint parameter to enable the breakpoints.
    This command is the equivalent of “Enable-PSBreakpoint -Id 3, 5″.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113295
    about_debuggers
    Set-PSBreakpoint
    Disable-PSBreakpoint
    Get-PSBreakpoint
    Remove-PSBreakpoint
    Get-PSCallStack

Disable-PSBreakpoint

NAME
    Disable-PSBreakpoint

SYNOPSIS
    Disables the breakpoints in the current console.

SYNTAX
    Disable-PSBreakpoint [-Id] <Int32[]> [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

    Disable-PSBreakpoint [-Breakpoint] <Breakpoint[]> [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Disable-PSBreakpoint cmdlet disables breakpoints, which assures that they are not hit when the script runs. You can use it to disable all breakpoints, or you can specify breakpoints by submitting breakpoint objects or breakpoint IDs.

    Technically, this cmdlet changes the value of the Enabled property of a breakpoint object to False. To re-enable a breakpoint, use the Enable-PSBreakpoint cmdlet. Breakpoints are enabled by default when you create them by using the Set-PSBreakpoint cmdlet.

    A breakpoint is a point in a script where execution stops temporarily so that you can examine the instructions in the script. Disable-PSBreakpoint is one of several cmdlets designed for debugging Windows PowerShell scripts. For more information about the Windows PowerShell debugger, see about_debuggers.

PARAMETERS
    -Breakpoint <Breakpoint[]>
        Specifies the breakpoints to disable. Enter a Variable that contains breakpoint objects or a command that gets breakpoint objects, such as a Get-PSBreakpoint command. You can also pipe breakpoint objects to the Disable-PSBreakpoint cmdlet.

        Required?                    true
        Position?                    1
        Default value                None
        Accept pipeline input?     true (ByValue)
        Accept wildcard characters? false

    -Id <Int32[]>
        Disables the breakpoints with the specified breakpoint IDs. Enter the IDs or a Variable that contains the IDs. You cannot pipe IDs to Disable-PSBreakpoint.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     true (ByPropertyName)
        Accept wildcard characters? false

    -PassThru [<SwitchParameter>]
        Returns an object representing the enabled breakpoints. By default, this cmdlet does not generate any output.

        Required?                    false
        Position?                    named
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -WhatIf [<SwitchParameter>]
        Describes what would happen if you executed the command without actually executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.Management.Automation.Breakpoint
        You can pipe a breakpoint object to Disable-PSBreakpoint.

OUTPUTS
    None or System.Management.Automation.Breakpoint
        When you use the PassThru parameter, Disable-PSBreakpoint returns an object that represents the disabled breakpoint. Otherwise, this cmdlet does not generate any output.

NOTES

    ————————– EXAMPLE 1 ————————–

    C:\PS>$b = Set-PSBreakpoint -script sample.ps1 -variable name

    C:\PS> $b | Disable-PSBreakpoint

    Description
    ———–
    These commands disable a newly-created breakpoint.

    The first command uses the Set-PSBreakpoint cmdlet to create a breakpoint on the Name Variable in the Sample.ps1 script. Then, it saves the breakpoint object in the $b Variable.

    The second command uses the Disable-PSBreakpoint cmdlet to disable the new breakpoint. It uses a pipeline operator (|) to send the breakpoint object in $b to the Disable-PSBreakpoint cmdlet.

    As a result of this command, the value of the Enabled property of the breakpoint object in $b is False.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Disable-PSBreakpoint -id 0

    Description
    ———–
    This command disables the breakpoint with breakpoint ID 0.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Disable-PSBreakpoint -Breakpoint ($b = Set-PSBreakpoint -script sample.ps1 -line 5)

    C:\PS> $b

    Description
    ———–
    This command creates a new breakpoint that is disabled until you enable it.

    It uses the Disable-PSBreakpoint cmdlet to disable the breakpoint. The value of the Breakpoint parameter is a Set-PSBreakpoint command that sets a new breakpoint, generates a breakpoint object, and saves the object in the $b Variable.

    Cmdlet parameters that take objects as their values can accept a Variable that contains the object or a command that gets or generates the object. In this case, because Set-PSBreakpoint generates a breakpoint object, it can be used as the value of the Breakpoint parameter.

    The second command displays the breakpoint object in the value of the $b Variable.

    ————————– EXAMPLE 4 ————————–

    C:\PS>Get-PSBreakpoint | Disable-PSBreakpoint

    Description
    ———–
    This command disables all breakpoints in the current console. You can abbreviate this command as: “gbp | dbp”.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113294
    about_debuggers
    Set-PSBreakpoint
    Get-PSBreakpoint
    Enable-PSBreakpoint
    Remove-PSBreakpoint
    Get-PSCallStack