Поделиться через


Enable-PSBreakpoint

Enables the breakpoints in the current console.

Синтаксис

Breakpoint (по умолчанию)

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

Id

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

Описание

The Enable-PSBreakpoint cmdlet re-enables disabled breakpoints. You can use it to enable all breakpoints, or specific breakpoints by providing breakpoint objects or IDs.

A breakpoint is a point in a script where execution stops temporarily so that you can examine the state of the script. Newly created breakpoints are automatically enabled, but can be disabled using Disable-PSBreakpoint.

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 PowerShell scripts. For more information about the PowerShell debugger, see about_Debuggers.

Примеры

Example 1: Enable all breakpoints

This example enables all breakpoints in the current session.

Get-PSBreakpoint | Enable-PSBreakpoint

Using aliases, this example can be abbreviated as gbp | ebp.

Example 2: Enable breakpoints by ID

This example enables multiple breakpoints using their breakpoint IDs.

Enable-PSBreakpoint -Id 0, 1, 5

Example 3: Enable a disabled breakpoint

This example re-enables a breakpoint that has been disabled.

$B = Set-PSBreakpoint -Script "sample.ps1" -Variable Name -PassThru
$B | Enable-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

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

Set-PSBreakpoint creates a breakpoint on the Name variable in the Sample.ps1 script saving the breakpoint object in the $B variable. The PassThru parameter displays the value of the Enabled property of the breakpoint is False.

Enable-PSBreakpoint re-enables the breakpoint. Again, using the PassThru parameter we see that the value of the Enabled property is True.

Example 4: Enable breakpoints using a variable

This example enables a set of breakpoints using the breakpoint objects.

$B = Get-PSBreakpoint -Id 3, 5
Enable-PSBreakpoint -Breakpoint $B

Get-PSBreakpoint gets the breakpoints and saves them in the $B variable. Using the Breakpoint parameter, Enable-PSBreakpoint enables the breakpoints.

This example is equivalent to running Enable-PSBreakpoint -Id 3, 5.

Example 5: Enable a breakpoint in a runspace

In this example, a job is started with a breakpoint is set to break then disabled. The runspace is stored in a variable and passed to the Get-PSBreakpoint command with the Runspace parameter. The output of Get-PSBreakpoint is piped to Enable-PSBreakpoint to enable the breakpoint in the runspace.

Start-Job -ScriptBlock {
    $bp = Set-PSBreakpoint -Command Start-Sleep
    Disable-PSBreakpoint $bp
    Start-Sleep -Seconds 10
}

$runspace = Get-Runspace -Id 1

Get-PSBreakpoint -Runspace $runspace | Enable-Breakpoint -Runspace $runspace

Параметры

-Breakpoint

Specifies the breakpoints to enable. Provide a variable containing breakpoints or a command that gets breakpoint objects, such as Get-PSBreakpoint. You can also pipe breakpoint objects to Enable-PSBreakpoint.

Свойства параметра

Тип:

Breakpoint[]

Default value:None
Поддерживаются подстановочные знаки:False
DontShow:False

Наборы параметров

Breakpoint
Position:0
Обязательно:True
Значение из конвейера:True
Значение из конвейера по имени свойства:False
Значение из оставшихся аргументов:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Свойства параметра

Тип:SwitchParameter
Default value:False
Поддерживаются подстановочные знаки:False
DontShow:False
Aliases:cf

Наборы параметров

(All)
Position:Named
Обязательно:False
Значение из конвейера:False
Значение из конвейера по имени свойства:False
Значение из оставшихся аргументов:False

-Id

Specifies the Id numbers of the breakpoints to enable. The default value is all breakpoints. Provide the Id by number or in a variable. You can't pipe Id numbers to Enable-PSBreakpoint. To find the Id of a breakpoint, use the Get-PSBreakpoint cmdlet.

Свойства параметра

Тип:

Int32[]

Default value:None
Поддерживаются подстановочные знаки:False
DontShow:False

Наборы параметров

Id
Position:0
Обязательно:True
Значение из конвейера:False
Значение из конвейера по имени свойства:True
Значение из оставшихся аргументов:False

-PassThru

Returns an object representing the breakpoint being enabled. By default, this cmdlet doesn't generate any output.

Свойства параметра

Тип:SwitchParameter
Default value:None
Поддерживаются подстановочные знаки:False
DontShow:False

Наборы параметров

(All)
Position:Named
Обязательно:False
Значение из конвейера:False
Значение из конвейера по имени свойства:False
Значение из оставшихся аргументов:False

-Runspace

Specifies the Id of a Runspace object so you can interact with breakpoints in the specified runspace.

This parameter was added in PowerShell 7.2.

Свойства параметра

Тип:Runspace
Default value:None
Поддерживаются подстановочные знаки:False
DontShow:False
Aliases:RunspaceId

Наборы параметров

Id
Position:Named
Обязательно:False
Значение из конвейера:False
Значение из конвейера по имени свойства:True
Значение из оставшихся аргументов:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet isn't run.

Свойства параметра

Тип:SwitchParameter
Default value:False
Поддерживаются подстановочные знаки:False
DontShow:False
Aliases:wi

Наборы параметров

(All)
Position:Named
Обязательно:False
Значение из конвейера:False
Значение из конвейера по имени свойства:False
Значение из оставшихся аргументов:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Входные данные

Breakpoint

You can pipe a breakpoint object to this cmdlet.

Выходные данные

None

By default, this cmdlet returns no output.

Breakpoint

When you use the PassThru parameter, this cmdlet returns a breakpoint object representing the enabled breakpoint.

Примечания

PowerShell includes the following aliases for Enable-PSBreakpoint:

  • All platforms:

    • ebp
  • The Enable-PSBreakpoint cmdlet doesn't 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 don't need to enable newly created breakpoints.