NAME
Get-PSBreakpoint
SYNOPSIS
Gets the breakpoints that are set in the current session.
SYNTAX
Get-PSBreakpoint [[-Script] <string[]>] [<CommonParameters>]
Get-PSBreakpoint -Command <string[]> [-Script <string[]>] [<CommonParameters>]
Get-PSBreakpoint [-Id] <Int32[]> [<CommonParameters>]
Get-PSBreakpoint [-Type] <BreakpointType[]> [-Script <string[]>] [<CommonParameters>]
Get-PSBreakpoint -Variable <string[]> [-Script <string[]>] [<CommonParameters>]
DESCRIPTION
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 Windows PowerShell scripts and commands. For more information about the Windows PowerShell debugger, see about_debuggers.
PARAMETERS
-Command <string[]>
Gets command breakpoints that are set on the specified command names. Enter the command names, such as the name of a cmdlet or Function.
Required? true
Position? named
Default value All breakpoints
Accept pipeline input? false
Accept wildcard characters? false
-Id <Int32[]>
Gets the breakpoints with the specified breakpoint IDs. Enter the IDs in a comma-separated list. You can also pipe breakpoint IDs to Get-PSBreakpoint.
Required? true
Position? 1
Default value All breakpoints
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-Script <string[]>
Gets only the breakpoints in the specified scripts. Enter the path (optional) and names of one or more script files. The default location is the current directory.
Required? false
Position? named
Default value All breakpoints
Accept pipeline input? false
Accept wildcard characters? false
-Type <BreakpointType[]>
Gets only breakpoints of the specified types. Enter one or more types. Valid values are Line, Command, and Variable. You can also pipe breakpoint types to Get-PSBreakpoint.
Required? true
Position? 1
Default value All breakpoints
Accept pipeline input? true (ByValue)
Accept wildcard characters? false
-Variable <string[]>
Gets Variable breakpoints that are set on the specified Variable names. Enter the Variable names without dollar signs.
Required? true
Position? named
Default value All breakpoints
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
“Get-Help about_CommonParameters“.
INPUTS
System.Int32, Microsoft.PowerShell.Commands.BreakpointType
You can pipe breakpoint IDs and breakpoint types to Get-PSBreakpoint.
OUTPUTS
Breakpoint object (System.Management.Automation.LineBreakpoint, System.Management.Automation.VariableBreakpoint, System.Management.Automation.CommandBreakpoint)
Get-PSBreakpoint returns objects that represent the breakpoints in the session.
NOTES
You can use Get-PSBreakpoint or its Alias, “gbp”.
————————– EXAMPLE 1 ————————–
C:\PS>Get-PSBreakpoint
Description
———–
This command gets all breakpoints set on all scripts and Functions in the current session.
————————– EXAMPLE 2 ————————–
C:\PS>Get-PSBreakpoint -Id 2
Function : Increment
Action :
Enabled : True
HitCount : 0
Id : 2
Script : C:\ps-test\sample.ps1
ScriptName : C:\ps-test\sample.ps1
Description
———–
This command gets the breakpoint with breakpoint ID 2.
————————– EXAMPLE 3 ————————–
C:\PS>$b = Set-PSBreakpoint -Script sample.ps1 -function increment
C:\PS> $b.Id | Get-PSBreakpoint
Description
———–
These commands show how to get a breakpoint by piping a breakpoint ID to Get-PSBreakpoint.
The first command uses the Set-PSBreakpoint cmdlet to create a breakpoint on the Increment Function in the Sample.ps1 script. It saves the breakpoint object in the $b Variable.
The second command uses the dot operator (.) to get the Id property of the breakpoint object in the $b Variable. It uses a pipeline operator (|) to send the ID to the Get-PSBreakpoint cmdlet.
As a result, Get-PSBreakpoint gets the breakpoint with the specified ID.
————————– EXAMPLE 4 ————————–
C:\PS>Get-PSBreakpoint -Script Sample.ps1, SupportScript.ps1
Description
———–
This command gets all of the breakpoints in the Sample.ps1 and SupportScript.ps1 files.
This command does not get other breakpointS that might be set in other scripts or on Functions in the session.
————————– EXAMPLE 5 ————————–
C:\PS>Get-PSBreakpoint -command Read-Host, Write-Host -Script Sample.ps1
Description
———–
This command gets all Command breakpoints that are set on Read-Host or Write-Host commands in the Sample.ps1 file.
————————– EXAMPLE 6 ————————–
C:\PS>Get-PSBreakpoint -type Command -Script Sample.ps1
Description
———–
This command gets all Command breakpoints in the Sample.ps1 file.
————————– EXAMPLE 7 ————————–
C:\PS>Get-PSBreakpoint -variable Index, Swap
Description
———–
This command gets breakpoints that are set on the $index and $swap Variables in the current session.
————————– EXAMPLE 8 ————————–
C:\PS>Get-PSBreakpoint -type line, Variable -Script Sample.ps1
Description
———–
This command gets all line and Variable breakpoints in the Sample.ps1 script.
RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=113325
about_debuggers
Set-PSBreakpoint
Disable-PSBreakpoint
Enable-PSBreakpoint
Remove-PSBreakpoint
Get-PSCallStack