共用方式為


Get-PSBreakpoint

取得目前工作階段中設定的中斷點。

Syntax

Get-PSBreakpoint
   [[-Script] <string[]>]
   [<CommonParameters>]
Get-PSBreakpoint
   -Command <string[]>
   [-Script <string[]>]
   [<CommonParameters>]
Get-PSBreakpoint
   -Variable <string[]>
   [-Script <string[]>]
   [<CommonParameters>]
Get-PSBreakpoint
   [-Type] <BreakpointType[]>
   [-Script <string[]>]
   [<CommonParameters>]
Get-PSBreakpoint
   [-Id] <int[]>
   [<CommonParameters>]

Description

Cmdlet Get-PSBreakPoint 會取得目前會話中設定的斷點。 您可以使用 Cmdlet 參數以取得特定的中斷點。

中斷點是命令或指令碼中的暫時停止執行點,用來讓您檢查指示。 Get-PSBreakpoint 是針對偵錯 PowerShell 腳本和命令而設計的數個 Cmdlet 之一。 如需 PowerShell 調試程式的詳細資訊,請參閱 about_Debuggers

範例

範例 1:取得所有腳本和函式的所有斷點

此命令會取得在目前工作階段中之所有指令碼和函式上設定的所有中斷點。

Get-PSBreakpoint

範例 2:依標識碼取得斷點

此命令會取得具有中斷點識別碼 2 的中斷點。

Get-PSBreakpoint -Id 2

Function         :
IncrementAction  :
Enabled          :
TrueHitCount     : 0
Id               : 2
Script           : C:\ps-test\sample.ps1
ScriptName       : C:\ps-test\sample.ps1

範例 3:使用管線將標識符傳送至 'Get-PSBreakpoint'

這些命令會示範如何將斷點標識碼管線傳送至 Get-PSBreakpoint來取得斷點。

$B = `Set-PSBreakpoint` -Script "sample.ps1" -Command "Increment"
$B.Id | Get-PSBreakpoint

Cmdlet 會在 Set-PSBreakpoint 腳本中的 Sample.ps1 Increment 函式上建立斷點,並將斷點物件儲存在變數中 $B 。 變數中$B斷點物件的Id屬性會傳送至 Get-PSBreakpoint Cmdlet 以顯示斷點資訊。

範例 4:取得指定文本檔案中的斷點

此命令會取得和 SupportScript.ps1 檔案中的所有Sample.ps1斷點。

Get-PSBreakpoint -Script "Sample.ps1, SupportScript.ps1"

此命令不會取得在其他腳本或會話中函式上設定的其他斷點。

範例 5:取得指定 Cmdlet 中的斷點

此命令會取得在 或 Write-Host 檔案中Sample.ps1設定Read-Host的所有命令斷點。

Get-PSBreakpoint -Command "Read-Host, Write-Host" -Script "Sample.ps1"

範例 6:取得指定檔案中的命令斷點

Get-PSBreakpoint -Type Command -Script "Sample.ps1"

此命令會取得 Sample.ps1 檔案中的所有命令中斷點。

範例 7:依變數取得斷點

此命令會取得在目前會話的 $Index$Swap 變數上設定的斷點。

Get-PSBreakpoint -Variable "Index, Swap"

範例 8:取得檔案中的所有行和變數斷點

此命令會取得腳本中的所有 Sample.ps1 行和變數斷點。

Get-PSBreakpoint -Type Line, Variable -Script "Sample.ps1"

參數

-Command

指定在指定命令名稱上設定的命令斷點陣列。 輸入命令名稱,例如 Cmdlet 或函式的名稱。

Type:String[]
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Id

指定這個 Cmdlet 取得的斷點標識碼。 以逗號分隔的清單方式輸入識別碼。 您也可以使用管線將斷點識別碼傳送至 Get-PSBreakpoint

Type:Int32[]
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Script

指定包含斷點的文稿陣列。 輸入路徑 (選擇性) 和一或多個腳本檔案的名稱。 若省略路徑,則預設位置為目前目錄。

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Type

指定這個 Cmdlet 取得的斷點類型數位。 輸入一個或多個類型。 此參數可接受的值為:

  • 折線圖
  • 命令
  • 變數

您也可以使用管線將斷點類型傳送至 Get-PSBreakPoint

Type:BreakpointType[]
Accepted values:Line, Variable, Command
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Variable

指定在指定變數名稱上設定的變數斷點陣列。 輸入不含貨幣符號的變數名稱。

Type:String[]
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

輸入

Int32

BreakpointType

您可以使用管線將斷點識別碼和斷點類型傳送至 Get-PSBreakPoint

輸出

CommandBreakpoint

LineBreakpoint

VariableBreakpoint

Breakpoint

Get-PSBreakPoint 會傳回物件,代表會話中的斷點。

備註

您可以使用 Get-PSBreakpoint 或其別名 「gbp」。