Search code examples
powershellbatch-filepowershell-3.0powershell-remoting

Running remote power shell scripts in parallel


I want to call 4 different PowerShell scripts on 4 different Remote servers in parallel. I would like them to all execute at the same time and not wait for the first remote script execution to complete before the next job runs.

One solution I have considered is to call a batch file which in turn will call 4 remote scripts because invoke-command call will wait for the called script to complete.

I am new in scripting. Please let me know which way its possible.

Thanks, Hanu


Solution

  • You want to use background jobs in PowerShell. Check out the -AsJob parameter on Invoke-Command, and read the get-help about_jobs documentation for details on starting jobs and gathering up the output again when they are all done running.