Tag Archives: Id

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

Clear-History

NAME
    Clear-History

SYNOPSIS
    Deletes entries from the command history.

SYNTAX
    Clear-History [[-Id] <Int32[]>] [[-Count] <int>] [-Newest] [-Confirm] [-WhatIf] [<CommonParameters>]

    Clear-History [[-Count] <int>] [-CommandLine <string[]>] [-Newest] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Clear-History cmdlet deletes commands from the command history, that is, the list of commands entered during the current session.

    Without parameters, Clear-History deletes all commands from the session history, but you can use the parameters of Clear-History to delete selected commands.

PARAMETERS
    -CommandLine <string[]>
        Deletes commands with the specified text strings. If you enter more than one string, Clear-History deletes commands with any of the strings.

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

    -Count <int>
        Clears the specified number of history entries, beginning with the oldest entry in the history.

        If you use the Count and Id parameters in the same command, the cmdlet clears the number of entries specified by the Count parameter, beginning with the entry specified by the Id parameter. For example, if Count is 10 and Id is 30, Clear-History clears items 21 through 30 inclusive.

        If you use the Count and CommandLine parameters in the same command, Clear-History clears the number of entries specified by the Count parameter, beginning with the entry specified by the CommandLine parameter.

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

    -Id <Int32[]>
        Deletes commands with the specified history IDs.

        To find the history ID of a command, use Get-History.

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

    -Newest [<SwitchParameter>]
        Deletes the newest entries in the history. By default, Clear-History deletes the oldest entries in the history.

        Required?                    false
        Position?                    named
        Default value                False
        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
    None
        You cannot pipe objects to Clear-History.

OUTPUTS
    None
        This cmdlet does not generate any output.

NOTES

        The session history is a list of the commands entered during the session. You can view the history, add and delete commands, and run commands from the history. For more information, see about_History.

        Deleting a command from the history does not change the history IDs of the remaining items in the command history.

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

    C:\PS>Clear-History

    Description
    ———–
    Deletes all commands from the session history.

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

    C:\PS>Clear-History -Id 23, 25

    Description
    ———–
    Deletes the commands with history IDs 23 and 25.

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

    C:\PS>Clear-History -command *help*, *command

    Description
    ———–
    Deletes commands that include “help” or end in “command”.

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

    C:\PS>Clear-History -Count 10 -Newest

    Description
    ———–
    Deletes the 10 newest commands from the history.

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

    C:\PS>Clear-History -Id 10 -Count 3

    Description
    ———–
    Deletes the three oldest commands, beginning with the entry with ID 10.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=135199
    about_History
    Get-History
    Add-History
    Invoke-History