Remove-PSBreakpoint
從目前的主控台刪除中斷點。
Syntax
Remove-PSBreakpoint
[-Breakpoint] <Breakpoint[]>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-PSBreakpoint
[-Id] <Int32[]>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Cmdlet 會 Remove-PSBreakpoint
刪除斷點。 輸入中斷點物件或中斷點識別碼。
當您移除中斷點時,中斷點物件就無法再使用或運作。 如果您將中斷點物件儲存在變數中,參考仍然存在,但中斷點無法運作。
Remove-PSBreakpoint
是數個專為偵錯 PowerShell 腳本而設計的 Cmdlet 之一。 如需 PowerShell 調試程式的詳細資訊,請參閱 about_Debuggers。
範例
範例 1:移除所有中斷點
這個命令會刪除目前主控台中的所有中斷點。
Get-PSBreakpoint | Remove-PSBreakpoint
範例 2:移除指定的中斷點
此命令會刪除中斷點。
$B = Set-PSBreakpoint -Script "sample.ps1" -Variable "Name"
$B | Remove-PSBreakpoint
Cmdlet 會在Set-PSBreakpoint
腳本中的$Name
Sample.ps1
變數上建立斷點,並將斷點物件儲存在變數中$B
。 Cmdlet 會 Remove-PSBreakpoint
刪除新的斷點。 它會使用管線運算符 (|
) 將變數中的 $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,以刪除它們。
參數
-Breakpoint
指定要刪除的中斷點。 輸入包含斷點物件的變數,或取得斷點物件的命令,例如 Get-PSBreakpoint
命令。 您也可以使用管線將斷點物件傳送至 Remove-PSBreakpoint
。
Type: | Breakpoint[] |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Confirm
在執行 Cmdlet 前提示您確認。
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Id
指定此 Cmdlet 刪除其中斷點的中斷點識別碼。
Type: | Int32[] |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-WhatIf
顯示執行 Cmdlet 後會發生的情況。 Cmdlet 並不會執行。
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
輸入
您可以使用管線將斷點物件傳送至 Remove-PSBreakpoint
。
Int32[]
輸出
None
此 Cmdlet 不會產生任何輸出。