Remove-PSBreakpoint
从当前控制台中删除断点。
语法
Remove-PSBreakpoint
[-Breakpoint] <Breakpoint[]>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-PSBreakpoint
[-Id] <Int32[]>
[-Runspace <Runspace>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
说明
Remove-PSBreakpoint
cmdlet 删除断点。 输入断点对象或断点 ID。
删除断点时,断点对象不再可用或功能。 如果在变量中保存了断点对象,则引用仍然存在,但断点不起作用。
Remove-PSBreakpoint
是用于调试 PowerShell 脚本的多个 cmdlet 之一。 有关 PowerShell 调试器的详细信息,请参阅 about_Debuggers。
示例
示例 1:删除所有断点
此命令删除当前控制台中的所有断点。
Get-PSBreakpoint | Remove-PSBreakpoint
示例 2:删除指定的断点
此命令删除断点。
$B = Set-PSBreakpoint -Script "sample.ps1" -Variable "Name"
$B | Remove-PSBreakpoint
Set-PSBreakpoint
cmdlet 在 Sample.ps1
脚本中的 $Name
变量上创建断点,并将断点对象保存在 $B
变量中。
Remove-PSBreakpoint
cmdlet 将删除新的断点。 它使用管道运算符(|
)将 $B
变量中的断点对象发送到 Remove-PSBreakpoint
cmdlet。
由于此命令,如果运行脚本,它将在不停止的情况下运行到完成。 此外,Get-PSBreakpoint
cmdlet 不会返回此断点。
示例 3:按 ID 删除断点
此命令删除断点 ID 为 2 的断点。
Remove-PSBreakpoint -Id 2
示例 4:使用函数删除所有断点
此简单函数删除当前会话中的所有断点。
function del-psb { Get-PSBreakpoint | Remove-PSBreakpoint }
它使用 Get-PSBreakpoint
cmdlet 来获取断点。 然后,它使用管道运算符(|
)将断点发送到 Remove-PSBreakpoint
cmdlet,这将删除它们。
示例 5:删除运行空间中的断点
在此示例中,启动作业,并在运行 Set-PSBreakPoint
时将断点设置为中断。 runspace 存储在变量中,并使用 Runspace 参数传递给 Get-PSBreakPoint
命令。
Get-PSBreakPoint
的输出通过管道传递给 Remove-PSBreakpoint
以删除运行空间中的断点。
Start-Job -ScriptBlock {
Set-PSBreakpoint -Command Start-Sleep
Start-Sleep -Seconds 10
}
$runspace = Get-Runspace -Id 1
Get-PSBreakPoint -Runspace $runspace | Remove-Breakpoint -Runspace $runspace
参数
-Breakpoint
指定要删除的断点。 输入包含断点对象的变量或获取断点对象的命令,例如 Get-PSBreakpoint
命令。 还可以通过管道将断点对象传递给 Remove-PSBreakpoint
。
类型: | Breakpoint[] |
Position: | 0 |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-Confirm
在运行 cmdlet 之前,提示你进行确认。
类型: | SwitchParameter |
别名: | cf |
Position: | Named |
默认值: | False |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Id
指定此 cmdlet 删除断点的断点 ID。
类型: | Int32[] |
Position: | 0 |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-Runspace
指定 Runspace 对象的 ID,以便你可以与指定运行空间中的断点进行交互。
此参数已在 PowerShell 7.2 中添加。
类型: | Runspace |
别名: | RunspaceId |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-WhatIf
显示 cmdlet 运行时会发生什么情况。 cmdlet 未运行。
类型: | SwitchParameter |
别名: | wi |
Position: | Named |
默认值: | False |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
输入
可以通过管道将断点对象传递给此 cmdlet。
Int32[]
输出
None
此 cmdlet 不返回任何输出。
备注
PowerShell 包含以下 Remove-PSBreakpoint
别名:
- 所有平台:
rbp