Search code examples
powershelljobsinvoke-command

invoke-command $list .\script.ps1 -asjob, many child jobs stay at 'notstarted' status


Here's an example script:

sleep 3600

If I run it like this on a group of computers, a lot of them stay at 'notstarted' status:

$list = cat hps.txt # 190 computers
invoke-command $list .\script.ps1 -asjob

sleep 60; job -includechildjob | ? state -eq notstarted  # 157 not started

Solution

  • Check out the ThrottleLimit parameter on Invoke-Command;

    It limits how many concurrent connections Invoke-Command will open at one time; the default is 32, which looks like what you're running into (190 - 32 = 158).