13 Remote control: One-to-one and one-to-many
Let’s take a look at the Invoke-ScriptBlock
command. Notice that it has a -ComputerName
parameter. Hmmm . . . does that mean it can run commands on other hosts too? After a bit of experimenting, you’ll discover that’s exactly what it does. How many other commands have the ability to connect to remote machines? While there is not a way to obtain a concrete number to answer this question, there are quite a lot.
What we’ve 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 ...
Get Learn PowerShell in a Month of Lunches, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.