Remove-PSBreakpoint
从当前控制台中删除断点。
语法
Remove-PSBreakpoint
[-Breakpoint] <Breakpoint[]>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-PSBreakpoint
[-Id] <Int32[]>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
说明
Remove-PSBreakpoint cmdlet 删除断点。 输入断点对象或断点 ID。
删除断点时,断点对象不再可用或功能。 如果在变量中保存了断点对象,则引用仍然存在,但断点不起作用。
Remove-PSBreakpoint 是用于调试 Windows PowerShell 脚本的多个 cmdlet 之一。 有关 Windows PowerShell 调试器的详细信息,请参阅about_Debuggers。
示例
示例 1:删除所有断点
PS C:\> Get-PSBreakpoint | Remove-PSBreakpoint
此命令删除当前控制台中的所有断点。
示例 2:删除指定的断点
PS C:\> $B = Set-PSBreakpoint -Script "sample.ps1" -Variable "Name"
PS C:\> $B | Remove-PSBreakpoint
此命令删除断点。
第一个命令使用 Set-PSBreakpoint cmdlet 在 Sample.ps1 脚本中的 Name 变量上创建断点。 然后,它将断点对象保存在$B变量中。
第二个命令使用 Remove-PSBreakpoint cmdlet 删除新的断点。 它使用管道运算符 (|) 将 $B 变量中的断点对象发送到 Remove-PSBreakpoint cmdlet。
由于此命令,如果运行脚本,它将在不停止的情况下运行到完成。 此外,Get-PSBreakpoint cmdlet 不会返回此断点。
示例 3:按 ID 删除断点
PS C:\> Remove-PSBreakpoint -Id 2
此命令删除断点 ID 为 2 的断点。
示例 4:使用函数删除所有断点
PS C:\> function del-psb { get-psbreakpoint | remove-psbreakpoint }
此简单函数删除当前控制台中的所有断点。 它使用 Get-PSBreakpoint cmdlet 来获取断点。 然后,它使用管道运算符 (|) 将断点发送到 Remove-PSBreakpoint cmdlet,该 cmdlet 会将其删除。
因此,可以键入 del-psb
而不是较长的命令。
若要保存函数,请将其添加到 Windows PowerShell 配置文件。
参数
-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 |
-WhatIf
显示 cmdlet 运行时会发生什么情况。 cmdlet 未运行。
类型: | SwitchParameter |
别名: | wi |
Position: | Named |
默认值: | False |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
输入
可以通过管道将断点对象传递给 remove-PSBreakpoint
输出
None
该 cmdlet 不生成任何输出。