Run Commands Remotely With Invoke-Command

Execute script blocks on one or many hosts in parallel.

WindowsnetworksystemadminpowershellLow risk
Run Invoke-Command -ComputerName a,b -ScriptBlock { ... } to execute on both hosts.

01Command

Command
$ 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

RiskLow risk
RequirementsWindows 10/11 with PowerShell 5.1 or PowerShell 7+
!Warning: The script runs with the remote account's privileges; verify the account and test on one host before fanning out.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Invoke-Command
    Microsoft Learn · vendor-doc · 2026-09-20
    Evidence: Runs commands on local and remote computers.

Last verified: 2026-10-13 · Category: System & Settings

06Related solutions