Run Commands Remotely With Invoke-Command
Execute script blocks on one or many hosts in parallel.
01Command
$ Invoke-Command -ComputerName server01,server02 -ScriptBlock { Get-Service }02What it does
Invoke-Command sends a script block over WinRM to each listed computer and returns the serialized results as objects you can sort, export or pipe. It turns fleet-wide queries and changes into one scripted operation, which is a core advantage of remote shells.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Invoke-CommandEvidence: Runs commands on local and remote computers.
Last verified: 2026-10-13 · Category: System & Settings
06Related solutions
The nuclear option for broken connectivity: rebuild Winsock and the TCP/IP stack to defaults when adapters show 'no internet' despite everything else working.
A built-in PowerShell one-liner that answers 'is port 5432/3389/443 actually open through this network?' — no telnet client needed.
Configure a fixed IPv4 address, subnet mask and default gateway on any adapter in one line — essential for headless servers and remote workstations.