PowerShell Remoting
Separate where a command runs from how its results are returned.
Documentation: Microsoft Learn
Overview
PowerShell remoting runs commands in another session. Invoke-Command -ComputerName typically uses WSMan; SSH remoting uses different connection parameters and setup. A successful network connection does not by itself establish permission to use the PowerShell endpoint.
The example below is a plan: it creates one local object per server with a command stored as a string. It does not open a session or run Get-Service remotely. Use it to inspect the target list before writing an execution step.
For actual work, decide whether you need a one-time invocation or a reusable PSSession. Variables in the local session are not automatically variables in the remote session. Pass arguments or use the supported using scope syntax deliberately.
Returned objects may be deserialized snapshots with properties but without their original methods. Also, a remote server accessing a third server introduces a separate credential-delegation problem. Do not widen a file ACL merely because a second-hop request failed.
Inspect this example’s structure
Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.
$servers = 'WEB01' , 'WEB02' , 'SQL01'
foreach ($s in $servers) {
[pscustomobject]@{
ComputerName = $s
Command = 'Get-Service -Name Spooler'
} }- Stage 1$servers
Positional values or no named parameters
What happens
The three rows identify intended targets; they contain no service state. Before real execution, test one authorized target, capture its identity and inspect the returned properties. A row listing a command is not evidence that it succeeded.
Worth remembering
Verify target, endpoint permission, returned data and any second-hop requirement separately.
Primary documentation
Try it
Illustrative output · values vary by environment
Example reader
Inspect this page's example
Run supported commands against the practice data, or inspect the example without executing it.
Ready to inspect.
Shows the per-server result shape without making a network call.
Show reference output
Illustrative output · values vary by environment
ComputerName Command ------------ ------- WEB01 Get-Service -Name Spooler WEB02 Get-Service -Name Spooler SQL01 Get-Service -Name Spooler
Practise this
Read remote services
Read all service records from fictional lab-server. Use Invoke-Command -ComputerName lab-server -ScriptBlock. No network is contacted.
The sandbox is visible now. Sign in with Google only when you run or check a task; commands and temporary files are discarded when you leave.
Run a command to inspect its result.