Invoke-Command
noun
say it: “in-VOHK kuh-MAND” /ɪnˈvoʊk kəˈmænd/
A PowerShell command that runs a block of code on one or more other computers at once and brings back their answers, each labeled with the computer it came from.
What does Invoke-Command do?
Invoke-Command sends a script block, code in braces, to other computers like a note in an envelope, runs it on all of them at the same time and brings the answers back as objects. Each answer's PSComputerName says which computer it came from. The other computers need remoting turned on.
Invoke-Command -ComputerName front-desk, back-office, meeting-room -ScriptBlock {
Get-Service -Name Spooler
}
In a sentence
- “One Invoke-Command asked all three office PCs about the print service at the same time.”
- “Each answer from Invoke-Command carried a PSComputerName, so the stuck PC stood out.”
Level: Freelancer · More PowerShell terms at this level
Updated