liveBook · Manning

Remote chaining

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

Remote chaining is the practice of initiating a second remote connection from within an existing remote session.

Remote chaining starts a second remote connection from inside an existing session. It can create confusing connection paths and unnecessary server overhead, so avoid it unless the first computer must act as a middleman. section 13.5

Recognizing a second hop

After connecting from Ubuntu1 to SRV2, the prompt displays the remote computer name. Running Enter-PSSession again from that prompt creates a chain. This may be necessary when SRV2 sits behind a firewall, but it should not be the normal approach. section 13.5

Enter-PSSession -HostName Ubuntu1 -UserName tylerl
Enter-PSSession -ComputerName SRV2 -UserName contoso\tylerl

Use these commands to compare a direct connection with a second connection initiated from an existing remote session. section 13.5

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

How deep it goes
Explains the chain, its overhead, and its firewall exception, but defers detailed second-hop configuration.
Examples
Demonstrates Ubuntu1 connecting to SRV2 and then attempting another Enter-PSSession command.
What it assumes
Assumes an existing Enter-PSSession connection and teaches the second-hop gotcha during interactive remoting.
What you can do after
Diagnose a remoting chain by reading the prompt and avoid issuing further remote commands until returning to the local computer.
How it connects
Ties remote chaining to PowerShell remoting, one-to-one remoting, and the second hop.

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.