Tag Archives: Breakpoint

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

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