liveBook · Manning

Get-PSSession

As explained in Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

Get-PSSession is a PowerShell cmdlet that retrieves remoting sessions managed by the current PowerShell session.

Get-PSSession retrieves the remoting sessions currently maintained by PowerShell. It lets you reuse an existing connection instead of creating another one. section 18.1

Use the session list to:

  • View open sessions with Get-PSSession. section 18.1
  • Select a session by computer name, such as Get-PSSession -ComputerName SRV02. section 18.2
  • Pipe a selected session to Enter-PSSession or use it with Invoke-Command. section 18.2 section 18.6
  • Close sessions with Remove-PSSession when they are no longer needed. section 18.1

Enter a stored session

Get-PSSession -ComputerName SRV02 | Enter-PSSession This retrieves the session connected to SRV02 and passes its PSSession object directly to Enter-PSSession. Exiting the interactive shell leaves the session open for later use. section 18.2

PS C:\> get-pssession

Run Get-PSSession without parameters to display the open remoting sessions maintained by the current PowerShell session. section 18.1

How Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS covers it

How deep it goes
Explains listing, computer-name filtering, and pipeline use, without detailing session-object implementation internals.
Examples
Uses SRV02 filtering, Enter-PSSession pipelines, remote process and time-zone commands, and session cleanup.
What it assumes
Assumes basic PowerShell remoting familiarity and teaches session reuse after establishing sessions with New-PSSession.
What you can do after
Operate/configure reusable remoting sessions for interactive access, Invoke-Command tasks, and deliberate cleanup.
How it connects
Connects Get-PSSession with New-PSSession, Enter-PSSession, Invoke-Command, and Remove-PSSession.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS. The section links point to the parts of the book it draws on.