Condividi tramite


Get-PSBreakpoint

Gets the breakpoints that are set in the current session.

Sintassi

Line (impostazione predefinita).

Get-PSBreakpoint
    [[-Script] <String[]>]
    [-Runspace <Runspace>]
    [<CommonParameters>]

Command

Get-PSBreakpoint
    [[-Script] <String[]>]
    -Command <String[]>
    [-Runspace <Runspace>]
    [<CommonParameters>]

Variable

Get-PSBreakpoint
    [[-Script] <String[]>]
    -Variable <String[]>
    [-Runspace <Runspace>]
    [<CommonParameters>]

Type

Get-PSBreakpoint
    [[-Script] <String[]>]
    [-Type] <BreakpointType[]>
    [-Runspace <Runspace>]
    [<CommonParameters>]

Id

Get-PSBreakpoint
    [-Id] <Int32[]>
    [-Runspace <Runspace>]
    [<CommonParameters>]

Descrizione

The Get-PSBreakpoint cmdlet gets the breakpoints that are set in the current session. You can use the cmdlet parameters to get particular breakpoints.

A breakpoint is a point in a command or script where execution stops temporarily so that you can examine the instructions. Get-PSBreakpoint is one of several cmdlets designed for debugging PowerShell scripts and commands. For more information about the PowerShell debugger, see about_Debuggers.

Esempio

Example 1: Get all breakpoints for all scripts and functions

This command gets all breakpoints set on all scripts and functions in the current session.

Get-PSBreakpoint

Example 2: Get breakpoints by ID

This command gets the breakpoint with breakpoint ID 2.

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

Example 3: Pipe an ID to `Get-PSBreakpoint`

These commands show how to get a breakpoint by piping a breakpoint ID to Get-PSBreakpoint.

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

The Set-PSBreakpoint cmdlet creates a breakpoint on the Increment function in the Sample.ps1 script and saves the breakpoint object in the $B variable. The Id property of the breakpoint object in the $B variable is piped to the Get-PSBreakpoint cmdlet to display the breakpoint information.

Example 4: Get breakpoints in specified script files

This command gets all of the breakpoints in the Sample.ps1 and SupportScript.ps1 files.

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

This command does not get other breakpoints that might be set in other scripts or on functions in the session.

Example 5: Get breakpoints in specified cmdlets

This command gets all Command breakpoints that are set on Read-Host or Write-Host commands in the Sample.ps1 file.

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

Example 6: Get Command breakpoints in a specified file

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

This command gets all Command breakpoints in the Sample.ps1 file.

Example 7: Get breakpoints by variable

This command gets breakpoints that are set on the $Index and $Swap variables in the current session.

Get-PSBreakpoint -Variable "Index, Swap"

Example 8: Get all Line and Variable breakpoints in a file

This command gets all line and variable breakpoints in the Sample.ps1 script.

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

Example 9: Get the breakpoints set in a specific runspace

In this example, a job is started and a breakpoint is set to break when the Set-PSBreakpoint is run. The runspace is stored in a variable and passed to the Get-PSBreakpoint command with the Runspace parameter. You can then inspect the breakpoint in the $breakpoint variable.

Start-Job -ScriptBlock {
    Set-PSBreakpoint -Command Start-Sleep
    Start-Sleep -Seconds 10
}

$runspace = Get-Runspace -Id 1

$breakpoint = Get-PSBreakpoint -Runspace $runspace

Parametri

-Command

Specifies an array of command breakpoints that are set on the specified command names. Enter the command names, such as the name of a cmdlet or function.

Proprietà dei parametri

Tipo:

String[]

Valore predefinito:None
Supporta i caratteri jolly:False
DontShow:False

Set di parametri

Command
Posizione:Named
Obbligatorio:True
Valore dalla pipeline:False
Valore dalla pipeline in base al nome della proprietà:False
Valore dagli argomenti rimanenti:False

-Id

Specifies the breakpoint IDs that this cmdlet gets. Enter the IDs in a comma-separated list. You can also pipe breakpoint IDs to Get-PSBreakpoint.

Proprietà dei parametri

Tipo:

Int32[]

Valore predefinito:None
Supporta i caratteri jolly:False
DontShow:False

Set di parametri

Id
Posizione:0
Obbligatorio:True
Valore dalla pipeline:True
Valore dalla pipeline in base al nome della proprietà:False
Valore dagli argomenti rimanenti:False

-Runspace

Specifies the Id of a Runspace object so you can interact with breakpoints in the specified runspace.

This parameter was added in PowerShell 7.2.

Proprietà dei parametri

Tipo:Runspace
Valore predefinito:None
Supporta i caratteri jolly:False
DontShow:False

Set di parametri

(All)
Posizione:Named
Obbligatorio:False
Valore dalla pipeline:False
Valore dalla pipeline in base al nome della proprietà:False
Valore dagli argomenti rimanenti:False

-Script

Specifies an array of scripts that contain the breakpoints. Enter the path (optional) and names of one or more script files. If you omit the path, the default location is the current directory.

Proprietà dei parametri

Tipo:

String[]

Valore predefinito:None
Supporta i caratteri jolly:False
DontShow:False

Set di parametri

Script
Posizione:Named
Obbligatorio:False
Valore dalla pipeline:True
Valore dalla pipeline in base al nome della proprietà:False
Valore dagli argomenti rimanenti:False
Variable
Posizione:Named
Obbligatorio:False
Valore dalla pipeline:True
Valore dalla pipeline in base al nome della proprietà:False
Valore dagli argomenti rimanenti:False
Command
Posizione:Named
Obbligatorio:False
Valore dalla pipeline:True
Valore dalla pipeline in base al nome della proprietà:False
Valore dagli argomenti rimanenti:False
Type
Posizione:Named
Obbligatorio:False
Valore dalla pipeline:True
Valore dalla pipeline in base al nome della proprietà:False
Valore dagli argomenti rimanenti:False

-Type

Specifies an array of breakpoint types that this cmdlet gets. Enter one or more types. The acceptable values for this parameter are:

  • Line
  • Command
  • Variable

You can also pipe breakpoint types to Get-PSBreakpoint.

Proprietà dei parametri

Tipo:

BreakpointType[]

Valore predefinito:None
Valori accettati:Line, Variable, Command
Supporta i caratteri jolly:False
DontShow:False

Set di parametri

Type
Posizione:0
Obbligatorio:True
Valore dalla pipeline:True
Valore dalla pipeline in base al nome della proprietà:False
Valore dagli argomenti rimanenti:False

-Variable

Specifies an array of variable breakpoints that are set on the specified variable names. Enter the variable names without dollar signs.

Proprietà dei parametri

Tipo:

String[]

Valore predefinito:None
Supporta i caratteri jolly:False
DontShow:False

Set di parametri

Variable
Posizione:Named
Obbligatorio:True
Valore dalla pipeline:False
Valore dalla pipeline in base al nome della proprietà:False
Valore dagli argomenti rimanenti:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Input

Int32

You can pipe breakpoint IDs to this cmdlet.

BreakpointType

You can pipe breakpoint types to this cmdlet.

Output

CommandBreakpoint

LineBreakpoint

VariableBreakpoint

Breakpoint

This cmdlet returns objects that represent the breakpoints in the session.

Note

PowerShell includes the following aliases for Get-PSBreakpoint:

  • All platforms:
    • gbp