liveBook · Manning

Chapter 13: Remote control: One-to-one and one-to-many

What you will learn in chapter 13 of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

Introduces PowerShell remoting as a shell-wide way to run commands on other computers without requiring every cmdlet to provide its own remote-connection parameter.

After this chapter you will be able to

What it builds on

Section by section

Introduction

Introduces PowerShell remoting as a shell-wide way to run commands on other computers without requiring every cmdlet to provide its own remote-connection parameter.

Key terms: remoting, cmdlet, Invoke-Command, -ComputerName

13.1 The idea behind remote PowerShell

This section explains where a remote PowerShell command runs and what returns to the user's computer.

Key terms: remote PowerShell, remote computer, results

13.1.1 Remoting on Windows devices

Explains the protocol and Windows service behind PowerShell remoting on Windows devices.

Key terms: Web Services for Management (WSMan), HTTP, HTTPS, Windows Remote Management (WinRM), group policy

13.1.2 Remoting on macOS and Linux devices

Explains why PowerShell remoting on macOS and Linux uses SSH and notes that SSH can also be used for remoting into Windows.

Key terms: WSMan, WinRM, Secure Shell (SSH), OpenSSH, PowerShell remoting protocol (PSRP)

13.1.3 Cross-platform remoting

This section explains how remote PowerShell returns objects, why those objects have limitations, and what setup is needed to follow the remoting examples.

Key terms: serialization, deserialization, XML, output objects, deserialized objects, snapshots, memory usage, CPU utilization, PowerShell v7.1, domain

13.2 Setting up PSRP over SSH

13.2.1 macOS and Linux

This subsection outlines the macOS and Ubuntu setup sequence for PSRP over SSH.

Key terms: SSH server, SSH client, PSRP over SSH, OpenSSH service

13.2.2 Setting up SSH on Windows

This section outlines how to set up PowerShell remoting over SSH on Windows and cautions readers to secure the SSH server and private key.

Key terms: OpenSSH client and server, OpenSSH-Server-In-TCP, sshd_config, Subsystem for PowerShell, OpenSSH service, OpenSSH, private-key authentication, private key

13.3 PSRP over SSH overview

The section explains where PSRP-over-SSH remoting must be enabled and how SSH routes incoming PowerShell connections.

Key terms: PSRP over SSH, PowerShell remoting, incoming commands, sshd listener, subsystem, PSRP, PowerShell, endpoint

13.4 WinRM overview

This section explains how WinRM receives and routes remote commands, how to enable PowerShell remoting on Windows, and two practical configuration considerations.

Key terms: WinRM, listener, endpoint, session configurations, Enable-PSRemoting, Set-WSManQuickConfig, WinRM service, Windows Firewall exception, Public, Work

13.5 Using Enter-PSSession and Exit-PSSession for one-to-one remoting

This section explains how to enter, use, and leave a one-to-one PowerShell remoting session, including its limits and common pitfalls.

Key terms: one-to-one remoting, shell prompt, -HostName, -ComputerName, SSH, WinRM, Enter-PSSession, Exit-PSSession, credentials, PowerShell profile script

13.6 Using Invoke-Command for one-to-many remoting

This section shows how Invoke-Command sends work to multiple remote computers and explains the syntax for commands, scripts, and computer lists.

Key terms: Invoke-Command, one-to-many, 1:N remoting, -throttleLimit, curly braces, Where-Object, -ScriptBlock, script file, -HostName, Get-Content

13.7 Differences between remote and local commands

Introduces a forthcoming comparison of Invoke-Command with local command execution and other forms of remote connectivity.

13.7.1 Deserialized objects

Explains why objects returned by remoting lose most methods and why actions on them should run on the remote computer.

Key terms: deserialized objects, methods, read-only copy, script block

13.7.2 Local vs. remote processing

This section explains why processing should happen on the remote computer before Invoke-Command returns results, especially when filtering data or changing remote processes.

Key terms: Invoke-Command, Where, serialized, deserialized, Get-Process, Stop-Process, action cmdlets

13.8 But wait, there’s more

This section contrasts hostname-based ad hoc remoting with reusable connections and explains how security restrictions can affect remoting.

Key terms: ad hoc remoting connections, hostnames, reusable, persistent connections, PowerShell remoting, security policies, firewalls, SSH, WinRM

13.9 Common points of confusion

This section explains two common remoting surprises: connection setup may need troubleshooting, and separate command invocations do not retain one another’s state.

Key terms: remoting, domain, about_remote_troubleshooting, invocation, remote computer, PowerShell

13.10 Lab

13.11 Lab answers

13.12 Further exploration

This section points readers to a free, periodically updated guide for more detailed PowerShell remoting configuration and troubleshooting.

Where this is used later

Concepts explained in this chapter

← Chapter 12: Filtering and comparisons Chapter 14: Multitasking with background jobs →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.