Run N parallel jobs in powershell

后端 未结 6 1545
忘了有多久
忘了有多久 2020-12-07 23:18

I have the following powershell script

$list = invoke-sqlcmd \'exec getOneMillionRows\' -Server...
$list | % {
    GetData $_ > $_.txt
    ZipTheFile $_.t         


        
6条回答
  •  难免孤独
    2020-12-08 00:09

    Background jobs is the answer. You can also throttle the jobs in the run queue using [System.Collection.Queue]. There is a blog post from PowerShell team on this topic: http://blogs.msdn.com/b/powershell/archive/2011/04/04/scaling-and-queuing-powershell-background-jobs.aspx

    Using queuing method is probably the best answer to throttling background jobs.

提交回复
热议问题