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

When we first started to use PowerShell (in version 1), we were playing around with the Get-Service command and noticed that it had a -computerName parameter. Hmmm... does that mean it can get services from other computers too? After a bit of experimenting, we discovered that’s exactly what it did. We were excited and started to look for -computerName parameters on other cmdlets. But we were disappointed to find there were only a few. With v2, a few more were added, but the number of commands that have this parameter is vastly outnumbered by the commands that don’t.

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 -computerName 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.

13.1. The idea behind remote PowerShell

13.2. WinRM overview

13.3. Using Enter-PSSession and Exit-PSSession for one-to-one remoting

13.4. Using Invoke-Command for one-to-many remoting

13.5. Differences between remote and local commands

13.6. But wait, there’s more

13.7. Remote options

13.8. Common points of confusion

13.9. Lab

13.10. Further exploration

13.11. Lab answers