How to execute a PowerShell function several times in parallel?

后端 未结 5 1268
情歌与酒
情歌与酒 2020-12-05 00:30

I\'m not sure whether to call this a need for multi-threading, job-based, or async, but basically I have a Powershell script function that takes several parameters and I nee

5条回答
  •  生来不讨喜
    2020-12-05 00:42

    I'm sorry that everyone missed your issue - I know it is far too late now, but...

    This error is caused because you are missing a comma between $username and $password in your list.

    You can test it out with this snippet, which I modelled off of the previous answers:

    $cmd = {
      param($a, $b, $c, $d)
    }
    $foo = "foo"
    $bar = "bar"
    start-job -scriptblock $cmd -ArgumentList "a", $foo, $bar, "gold" #added missing comma for this to work
    

提交回复
热议问题