Skip to content

Instantly share code, notes, and snippets.

@aytch
Last active January 15, 2020 15:20
Show Gist options
  • Save aytch/d453a7c23dfcad8f08bb744de3d5ba08 to your computer and use it in GitHub Desktop.
Save aytch/d453a7c23dfcad8f08bb744de3d5ba08 to your computer and use it in GitHub Desktop.
$serverlist = "server1","server2"
# `%{}` is shorthand for ForEach-Object.
# `$_` is a special variable that refers to "this" item in the array.
$serverlist | %{ Invoke-Command -ComputerName $_ -AsJob -ScriptBlock { <some commands> } }
# To view results of jobs
Get-Job | Receive-Job
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment