Invoke-Command
CautionRun commands remotely
Invoke-Command -ComputerName <host> -ScriptBlock {...}
Fan-out execution over WinRM — audit or configure many servers at once (needs PSRemoting).
Examples
Invoke-Command -ComputerName srv01,srv02 -ScriptBlock { Get-Service spooler }Check a service on many hosts
Syntax
Invoke-Command -ComputerName <hosts> -ScriptBlock {cmd}
Before you run it
Mass execution means mass impact.
Related commands
- Enter-PSSessionInteractive remote session
- sshRemote shell
The same reference, with no signal at all
Every command on this site, held on your device. The app adds 632 more: 1,510 commands and 120 fix flows, searchable with no connection. Free to install, no ads (some content is a one-time purchase).
Get it free on the App Store