Get-PSBreakpoint
取得目前會話中設定的斷點。
語法
Script (預設值)
Get-PSBreakpoint
[[-Script] <String[]>]
[<CommonParameters>]
Type
Get-PSBreakpoint
[[-Script] <String[]>]
[-Type] <BreakpointType[]>
[<CommonParameters>]
Command
Get-PSBreakpoint
[[-Script] <String[]>]
-Command <String[]>
[<CommonParameters>]
Variable
Get-PSBreakpoint
[[-Script] <String[]>]
-Variable <String[]>
[<CommonParameters>]
Id
Get-PSBreakpoint
[-Id] <Int32[]>
[<CommonParameters>]
Description
Get-PSBreakPoint Cmdlet 會取得目前會話中設定的斷點。 您可以使用 Cmdlet 參數來取得特定的斷點。
斷點是命令或文稿中的一個點,執行會暫時停止,以便您可以檢查指示。 Get-PSBreakpoint 是數個 Cmdlet 之一,專為偵錯 Windows PowerShell 腳本和命令而設計。 如需 Windows PowerShell 調試程式的詳細資訊,請參閱about_Debuggers。
範例
範例 1:取得所有腳本和函式的所有斷點
PS C:\> Get-PSBreakpoint
此命令會取得目前會話中所有腳本和函式上設定的所有斷點。
範例 2:依標識碼取得斷點
PS C:\> Get-PSBreakpoint -Id 2
Function :
IncrementAction :
Enabled :
TrueHitCount : 0
Id : 2
Script : C:\ps-test\sample.ps1
ScriptName : C:\ps-test\sample.ps1
此命令會取得斷點標識碼為 2 的斷點。
範例 3:使用管線將標識碼傳送至 Get-PSBreakpoint
PS C:\> $B = Set-PSBreakpoint -Script "sample.ps1" -Command "Increment"
PS C:\> $B.Id | Get-PSBreakpoint
這些命令示範如何將斷點標識符管線傳送至 get-PSBreakpoint
第一個命令會使用 Set-PSBreakpoint Cmdlet,在 Sample.ps1 腳本的 Increment 函式上建立斷點。 它會將斷點物件儲存在 $B 變數中。
第二個命令會使用點運算符 (.) 取得$B變數中斷點物件的Id屬性。 它會使用管線運算符 (|) 將標識符傳送至 get-PSBreakpoint Cmdlet
因此,Get-PSBreakpoint 取得具有指定標識碼的斷點。
範例 4:取得指定文本檔案中的斷點
PS C:\> Get-PSBreakpoint -Script "Sample.ps1, SupportScript.ps1"
此命令會取得 Sample.ps1 和 SupportScript.ps1 檔案中的所有斷點。
此命令不會取得其他斷點,這些斷點可能會在其他腳本或會話中的函式上設定。
範例 5:取得指定 Cmdlet 中的斷點
PS C:\> Get-PSBreakpoint -Command "Read-Host, Write-Host" -Script "Sample.ps1"
此命令會取得在 Read-Host 或 Write-Host 命令上設定的所有命令斷點,這些斷點位於 Sample.ps1 檔案中。
範例 6:取得指定檔案中的命令斷點
PS C:\> Get-PSBreakpoint -Type Command -Script "Sample.ps1"
此命令會取得 Sample.ps1 檔案中的所有命令斷點。
範例 7:依變數取得斷點
PS C:\> Get-PSBreakpoint -Variable "Index, Swap"
此命令會取得在目前會話中$Index和$Swap變數上設定的斷點。
範例 8:取得檔案中的所有行和變數斷點
PS C:\> Get-PSBreakpoint -Type Line, Variable -Script "Sample.ps1"
此命令會取得 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: | 0 |
| 必要: | False |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
Type
| Position: | 0 |
| 必要: | False |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
Command
| Position: | 0 |
| 必要: | False |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
Variable
| Position: | 0 |
| 必要: | False |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Type
指定這個 Cmdlet 取得的斷點類型數位。 輸入一或多個類型。 此參數可接受的值為:
- 線
- 指令
- 變數
您也可以使用管線將斷點類型傳送至 get-PSBreakPoint
參數屬性
| 類型: | BreakpointType[] |
| 預設值: | 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。
輸入
System.Int32, Microsoft.PowerShell.Commands.BreakpointType
您可以使用管線將斷點識別碼和斷點類型傳送至 get-PSBreakPoint 。
輸出
Breakpoint
Get-PSBreakPoint 會傳回代表會話中斷點的物件。
備註
- 您可以使用 Get-PSBreakpoint 或其別名 「gbp」。