Get PSBreakpoint - PowerShell


Overview

The Get-PSBreakpoint retrieves details about PSBreakpoints in the current PowerShell session or in another session specified through the -PSSession parameter. PSBreakpoints are used to halt the execution of a PowerShell script or command at a specified location and allow for debugging or inspection.

Syntax

Get-PSBreakpoint [-Session <PSSession>] [[-Id] <Int32>] [-Confirm] [-Debug <Boolean>] [-PassThru] [-ThrottleLimit <Int32>] [-Wait <Boolean>] [<CommonParameters>]

Options/Flags

  • -Session : Specifies the PSSession object that represents the remote session in which to retrieve PSBreakpoints. If not specified, the command operates in the current session.
  • -Id : Retrieves the PSBreakpoint object with the specified ID. If no ID is specified, the command returns all PSBreakpoints in the session.
  • -Confirm: Prompts for confirmation before executing the command.
  • -Debug: Generates verbose output for troubleshooting purposes.
  • -PassThru: Returns the PSBreakpoint object(s) instead of creating a formatted display.
  • -ThrottleLimit : Specifies the maximum number of concurrent operations that can be performed.
  • -Wait: Suspends the command execution until the PSBreakpoint is hit or removed.

Examples

Get all PSBreakpoints in the current session:

Get-PSBreakpoint

Get a specific PSBreakpoint by ID:

Get-PSBreakpoint -Id 123

Get PSBreakpoints in a remote session:

$session = New-PSSession -ComputerName remote-computer
Get-PSBreakpoint -Session $session

Return PSBreakpoint objects:

Get-PSBreakpoint -PassThru | Out-String

Wait for a PSBreakpoint to be hit:

Get-PSBreakpoint -Wait

Common Issues

  • The Get-PSBreakpoint command may fail if the specified PSSession is not valid or has expired.
  • If no PSBreakpoints are found, the command returns an empty result.

Integration

The Get-PSBreakpoint command can be used in conjunction with other PowerShell commands for advanced debugging scenarios, such as:

  • Set-PSBreakpoint: Set a new PSBreakpoint.
  • Remove-PSBreakpoint: Remove an existing PSBreakpoint.
  • Invoke-Command: Execute a command with PSBreakpoints enabled.
  • Get-PSSession: Retrieves PSSession objects.
  • Set-PSSessionConfiguration: Creates or modifies the configuration for a PSSession.
  • Set-PSBreakpoint: Sets a new PSBreakpoint.