Remove-PSBreakpoint
刪除目前控制台的斷點。
語法
Breakpoint (預設值)
Remove-PSBreakpoint
[-Breakpoint] <Breakpoint[]>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Id
Remove-PSBreakpoint
[-Id] <Int32[]>
[-Runspace <Runspace>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
指令 Remove-PSBreakpoint 長刪除了一個斷點。 輸入斷點物件或斷點 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指令本在腳本中為變數Sample.ps1建立斷點$Name,並將斷點物件保存在變$B數中。
Remove-PSBreakpoint指令長刪除了新的斷點。 它使用管線運算子(|)將變數中的 $B 斷點物件傳送給 Remove-PSBreakpoint cmdlet。
因此,執行腳本後,它會持續執行至完成。 此外, Get-PSBreakpoint 指令小子不會回傳這個斷點。
範例 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 會儲存在變數中,並使用 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。
參數屬性
| 類型: | |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
Breakpoint
| Position: | 0 |
| 必要: | True |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Confirm
在執行 Cmdlet 之前,提示您進行確認。
參數屬性
| 類型: | SwitchParameter |
| 預設值: | False |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | 參見 |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Id
指定斷點 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