How do you increase the number of processes in parallel with Powershell 3?

佐手、 提交于 2020-01-03 18:42:13

问题


I am trying to run 20 processes in parallel. I changed the session as below, but having no luck. I am getting only up to 5 parallel processes per session.

$wo=New-PSWorkflowExecutionOption -MaxSessionsPerWorkflow 50 -MaxDisconnectedSessions 200 -MaxSessionsPerRemoteNode 50 -MaxActivityProcesses 50
Register-PSSessionConfiguration -Name ITWorkflows -SessionTypeOption $wo -Force
Get-PSSessionConfiguration ITWorkflows | Format-List -Property *

Is there a switch parameter to increase the number of processes?

This is what I am running:

Workflow MyWorkflow1
{
Parallel {
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns  "where OrderId between 2 and 2975416"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 2975417 and 5950831"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 5950832 and 8926246"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 8926247 and 11901661"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 11901662 and 14877076"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns"where OrderId between 14877077 and 17852491"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns  "where OrderId between 17852492 and 20827906"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 20827907 and 23803321"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 23803322 and 26778736"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 26778737 and 29754151"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 29754152 and 32729566"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 32729567 and 35704981"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 35704982 and 38680396"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 38680397 and 432472144"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 432472145 and 435447559"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns  "where OrderId between 435447560 and 438422974"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 864944289 and 867919703"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 867919704 and 870895118"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 870895119 and 1291465602"}
InlineScript { import-module \\PS_Scripts\bulkins.ps1; BulkIns "where OrderId between 1291465603 and 1717986945"}
         }

回答1:


I'm not sure why you are calling PSSessionConfiguration.

If you look at the help output for New-PsWorkFlowSession, you may see a couple of examples that seem closer to what you want to do. I don't have the module you are using to test this workflow so I can't offer much more help.




回答2:


That should work you don't even need to change your PSSessionConfiguration. Here's an example since we don't have your module.

Workflow Get-ParallelChildItem
{
        Parallel {
        InlineScript {gci C:\ -Recurse}
        InlineScript {gci C:\ -Recurse}
        }
}



回答3:


jrv from the MSDN forums provides a working code sample:

$wo = New-PSWorkflowExecutionOption -MaxSessionsPerWorkflow 100 -MaxDisconnectedSessions 200
Register-PSSessionConfiguration -Name test-ping -SessionTypeOption $wo -Force

$s = New-PSWorkflowSession 
Invoke-Command $s { 
workflow Invoke-ParallelForEach{ 
    foreach -parallel ($i in 1..10){ 
        InlineScript{ 
            "foo: $using:i" 
        } 
        Get-Process -Name PowerShell* 
    } 
   } 
}

# now run the workflow with the custom configuration
Invoke-Command $s { Invoke-ParallelForEach -PSComputerName localhost -PSConfigurationName test-ping}


来源:https://stackoverflow.com/questions/12985392/how-do-you-increase-the-number-of-processes-in-parallel-with-powershell-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!