chapter thirteen

13 Remote control: one-to-one, and one-to-many

 

Let’s take a look at the Invoke-ScriptBlock command and notice that it had a -ComputerName parameter. Hmmm… does that mean it can run command other hosts too? After a bit of experimenting, we discovered that’s exactly what it did. How many other commands have the ability to connection to remote machines? While there is not a way to but a concrete number to this question there are quite alot.

What we’ve since realized is that PowerShell’s creators are a bit lazy—and that’s a good thing. Because they didn’t want to have to code a -HostName parameter for every single cmdlet, they created a shell-wide system called remoting. This system enables you to run any cmdlet on a remote computer. In fact, you can even run commands that exist on the remote computer but that don’t exist on your own computer—meaning you don’t always have to install every administrative cmdlet on your workstation. This remoting system is powerful, and it offers interesting administrative capabilities.

Note

 Remoting is a huge, complex technology. We introduce you to it in this chapter and cover usage scenarios that you’ll deal with 80 to 90% of the time. But we can’t cover it all, so in the “Further exploration” section at the end of this chapter, we point you to a must-have resource that covers remoting’s configuration options.

13.1 The idea behind remote PowerShell

13.1.1 Remoting on Windows Devices

13.1.2 Remoting on macOSX and Linux Devices

13.1.3 Cross Platform Remoting

13.2 Setup PSRP over SSH on

13.2.1 macOSX & Linux

13.2.2 Setting up SSH on Windows

13.3 PSRP over SSH overview

13.4 WinRm Overview

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

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

13.7 Differences between remote and local commands

13.7.1 Deserialized objects

13.7.2 Local vs. remote processing

13.8 But wait, there’s more

13.9 Common points of confusion

13.10 Lab

13.11 Further exploration

13.12 Lab answers