Disable-PSBreakpoint
Disables the breakpoints in the current console.
Синтаксис
Breakpoint (по умолчанию)
Disable-PSBreakpoint
[-Breakpoint] <Breakpoint[]>
[-PassThru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Id
Disable-PSBreakpoint
[-Id] <Int32[]>
[-PassThru]
[-Runspace <Runspace>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Описание
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 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
PowerShell scripts. For more information about the PowerShell debugger, see
about_Debuggers.
Примеры
Example 1: Set a breakpoint and disable it
These commands disable a newly-created breakpoint.
$B = Set-PSBreakpoint -Script "sample.ps1" -Variable "name"
$B | Disable-PSBreakpoint
The Set-PSBreakpoint
cmdlet creates a breakpoint on the $Name
variable in the Sample.ps1
script and saves the breakpoint object in the $B
variable. The Disable-PSBreakpoint
cmdlet
disables 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: Disable a breakpoint
This command disables the breakpoint with breakpoint ID 0.
Disable-PSBreakpoint -Id 0
Example 3: Create a disabled breakpoint
This command creates a new breakpoint that is disabled until you enable it.
Disable-PSBreakpoint -Breakpoint ($B = Set-PSBreakpoint -Script "sample.ps1" -Line 5)
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.
Example 4: Disable all breakpoints in the current console
This command disables all breakpoints in the current console.
`Get-PSBreakpoint` | Disable-PSBreakpoint
Example 5: Disable a breakpoint in a runspace
In this example, a job is started and a breakpoint is set to break when the Set-PSBreakpoint
is
run. 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 Disable-PSBreakpoint
to
disable the breakpoint in the runspace.
Start-Job -ScriptBlock {
Set-PSBreakpoint -Command Start-Sleep
Start-Sleep -Seconds 10
}
$runspace = Get-Runspace -Id 1
Get-PSBreakpoint -Runspace $runspace | Disable-Breakpoint -Runspace $runspace
Параметры
-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.
Свойства параметра
Тип: | |
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
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
.
Свойства параметра
Тип: | Int32[] |
Default value: | None |
Поддерживаются подстановочные знаки: | False |
DontShow: | False |
Наборы параметров
Id
Position: | 0 |
Обязательно: | True |
Значение из конвейера: | False |
Значение из конвейера по имени свойства: | True |
Значение из оставшихся аргументов: | False |
-PassThru
Returns an object representing the enabled breakpoints. By default, this cmdlet does not 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 is not 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 disabled breakpoint.
Примечания
PowerShell includes the following aliases for Disable-PSBreakpoint
:
- All platforms:
dbp