Get-PSBreakpoint
取得目前會話中設定的斷點。
語法
Line (預設值)
Get-PSBreakpoint
[[-Script] <string[]>]
[<CommonParameters>]
Command
Get-PSBreakpoint
-Command <string[]>
[-Script <string[]>]
[<CommonParameters>]
Variable
Get-PSBreakpoint
-Variable <string[]>
[-Script <string[]>]
[<CommonParameters>]
Type
Get-PSBreakpoint
[-Type] <BreakpointType[]>
[-Script <string[]>]
[<CommonParameters>]
Id
Get-PSBreakpoint
[-Id] <int[]>
[<CommonParameters>]
Description
Get-PSBreakPoint Cmdlet 會取得目前工作階段中設定的斷點。 您可以使用 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
Set-PSBreakpoint Cmdlet 會在 Sample.ps1 腳本中的 Increment 函式上建立斷點,並將斷點物件儲存在 $B 變數中。
變數中斷點物件的 $B 屬性會管線傳送至 Get-PSBreakpoint Cmdlet 以顯示斷點資訊。
範例 4:取得指定文本檔案中的斷點
此命令會取得 Sample.ps1 和 SupportScript.ps1 檔案中的所有斷點。
Get-PSBreakpoint -Script "Sample.ps1, SupportScript.ps1"
此命令不會取得其他斷點,這些斷點可能會在其他腳本或會話中的函式上設定。
範例 5:取得指定 Cmdlet 中的斷點
此命令會取得在 Read-Host 或 Write-Host 命令上設定的所有命令斷點,這些斷點位於 Sample.ps1 檔案中。
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 或函式的名稱。
參數屬性
| 類型: | String[] |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
Command
| Position: | Named |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Id
指定這個 Cmdlet 取得的斷點標識碼。 在逗號分隔清單中輸入標識碼。 您也可以使用管線將斷點識別碼傳送至 Get-PSBreakpoint。
參數屬性
| 類型: | Int32[] |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
Id
| Position: | 0 |
| 必要: | True |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Script
指定包含斷點的文稿陣列。 輸入一或多個腳本檔案的路徑(選擇性)和名稱。 如果您省略路徑,預設位置是目前目錄。
參數屬性
| 類型: | String[] |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
Script
| Position: | Named |
| 必要: | False |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
Variable
| Position: | Named |
| 必要: | False |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
Command
| Position: | Named |
| 必要: | False |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
Type
| Position: | Named |
| 必要: | False |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Type
指定這個 Cmdlet 取得的斷點類型數位。 輸入一或多個類型。 此參數可接受的值為:
- 線
- 指令
- 變數
您也可以使用管線將斷點類型傳送至 Get-PSBreakPoint。
參數屬性
| 類型: | |
| 預設值: | None |
| 接受的值: | Line, Variable, Command |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
Type
| Position: | 0 |
| 必要: | True |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Variable
指定在指定變數名稱上設定的變數斷點陣列。 輸入不含貨幣符號的變數名稱。
參數屬性
| 類型: | String[] |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
Variable
| Position: | Named |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
CommonParameters
此 Cmdlet 支援一般參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters。
輸入
Int32
BreakpointType
您可以將斷點 ID 和斷點類型通過導管傳輸到 Get-PSBreakPoint。
輸出
CommandBreakpoint
LineBreakpoint
VariableBreakpoint
Breakpoint
Get-PSBreakPoint 返回表示會話中斷點的物件。
備註
您可以使用 Get-PSBreakpoint 或其別名“gbp”。