共用方式為


Remove-PSBreakpoint

從目前的主控台刪除中斷點。

Syntax

Remove-PSBreakpoint
      [-Breakpoint] <Breakpoint[]>
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-PSBreakpoint
      [-Id] <Int32[]>
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

Remove-PSBreakpoint Cmdlet 會刪除中斷點。 輸入中斷點物件或中斷點識別碼。

當您移除中斷點時,中斷點物件就無法再使用或運作。 如果您將中斷點物件儲存在變數中,參考仍然存在,但中斷點無法運作。

Remove-PSBreakpoint 是數個專為偵錯 PowerShell 腳本而設計的 Cmdlet 之一。 如需 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︰依識別碼移除中斷點

PS C:\> Remove-PSBreakpoint -Id 2

此命令會刪除具有中斷點識別碼 2 的中斷點。

範例 4︰使用函式來移除所有中斷點

PS C:\> function del-psb { get-psbreakpoint | remove-psbreakpoint }

這個簡單函式會刪除目前主控台中的所有中斷點。 它會使用 Get-PSBreakpoint Cmdlet 取得中斷點。 然後,它會使用管線運算子 (|) 將中斷點傳送至會刪除這些中斷點的 Remove-PSBreakpoint Cmdlet。

如此一來,您可以輸入 del-psb,而不是較長的命令。

若要儲存函式,請將它新增至您的PowerShell配置檔。

參數

-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

輸入

Breakpoint

您可以使用管線將中斷點物件傳送至 Remove-PSBreakpoint

輸出

None

此 Cmdlet 不會產生任何輸出。