PowerShell Remoting Requirements
Remoting means running commands on another computer from your own. It needs matching software, permission, and proof of identity on both ends.
The local form runs on this machine
This Invoke-Command call has no computer name, so it runs here and not on a remote host.
Invoke-Command -ScriptBlock { "local run" }The local form reads plain variables
Locally the block runs in your own session, so a plain variable is already visible and $using: is not needed.
$place = "this machine"
Invoke-Command -ScriptBlock { "ran on: $place" }Requirements as a plain list
These are the pieces a real remote call needs, printed as words only.
@("WinRM on Windows", "OpenSSH on Linux and macOS", "Trusted hosts", "Credentials") -join "; "Example
$place = "this machine"
Invoke-Command -ScriptBlock { "Local only: ran on $place" }
@("WinRM", "OpenSSH", "Trusted hosts", "Credentials") -join ", "Key points
- Remoting: running a command on another computer instead of your own.
- WinRM: the Windows service that accepts remote PowerShell commands.
- OpenSSH: the tool that carries remote PowerShell on Linux and macOS.
- Trusted host: a computer that the receiving side has agreed to accept connections from.
- Credentials: proof of identity that the remote side checks before running anything.
- The remote forms, such as New-PSSession and -ComputerName, are not run in this course, because no remote host exists here.
In this example, the local Invoke-Command form prints a line that says plainly that the run stayed local, using a plain variable that the local block can already see. A second line then lists the four things a real remote call would need, as words only, with no remote host contacted.
Note
the local Invoke-Command form below runs on this machine only, and it shows the shape of a call without contacting any remote host.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
A Windows computer accepts remote PowerShell commands through which service?