Remove-PSBreakpoint
從目前的主控台刪除斷點。
語法
Breakpoint (預設值)
Remove-PSBreakpoint
[-Breakpoint] <Breakpoint[]>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Id
Remove-PSBreakpoint
[-Id] <Int32[]>
[-Runspace <Runspace>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Remove-PSBreakpoint Cmdlet 會刪除斷點。 輸入斷點對象或斷點標識碼。
當您移除斷點時,斷點對象將無法再使用或運作。 如果您已將斷點物件儲存在變數中,則參考仍然存在,但斷點無法運作。
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 會在 $Name 腳本中的 Sample.ps1 變數上建立斷點,並將斷點物件儲存在 $B 變數中。
Remove-PSBreakpoint Cmdlet 會刪除新的斷點。 它會使用管線運算符 (|) 將 $B 變數中的斷點對象傳送至 Remove-PSBreakpoint Cmdlet。
由於此命令,如果您執行腳本,它會在不停止的情況下執行至完成。 此外,Get-PSBreakpoint Cmdlet 不會傳回此斷點。
範例 3:依標識符移除斷點
此命令會刪除具有斷點標識碼 2 的斷點。
Remove-PSBreakpoint -Id 2
範例 4:使用函式移除所有斷點
這個簡單函式會刪除目前會話中的所有斷點。
function del-psb { Get-PSBreakpoint | Remove-PSBreakpoint }
它會使用 Get-PSBreakpoint Cmdlet 來取得斷點。 然後,它會使用管線運算符 (|) 將斷點傳送至 Remove-PSBreakpoint Cmdlet,以刪除它們。
範例 5:移除 Runspace 中的斷點
在此範例中,會啟動作業,並在執行 Set-PSBreakPoint 時,將斷點設定為中斷。 Runspace 會儲存在變數中,並使用 Get-PSBreakPoint 參數傳遞至 命令。
Get-PSBreakPoint 的輸出會透過管道傳送至 Remove-PSBreakpoint,以移除 Runspace 中的斷點。
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。
參數屬性
| 類型: | |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
Breakpoint
| Position: | 0 |
| 必要: | True |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Confirm
在執行 Cmdlet 之前,提示您進行確認。
參數屬性
| 類型: | SwitchParameter |
| 預設值: | False |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | cf |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Id
指定這個 Cmdlet 刪除斷點的斷點標識碼。
參數屬性
| 類型: | Int32[] |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
Id
| Position: | 0 |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-Runspace
指定 Runspace 物件的識別符,讓您可以在指定的 runspace 中與斷點互動。
此參數已在PowerShell 7.2中新增。
參數屬性
| 類型: | Runspace |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | RunspaceId |
參數集
Id
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-WhatIf
顯示 Cmdlet 執行時會發生什麼事。 指令未執行。
參數屬性
| 類型: | SwitchParameter |
| 預設值: | False |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | 無線 |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
CommonParameters
此 Cmdlet 支援一般參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters。
輸入
Breakpoint
您可以使用管線將斷點物件傳送至此 Cmdlet。
Int32
Runspace
輸出
None
此 Cmdlet 不會傳回任何輸出。
備註
PowerShell 包含下列 Remove-PSBreakpoint的別名:
- 所有平臺:
rbp