4

我正在尝试并行运行 20 个进程。我改变了会话如下,但没有运气。每个会话我最多只能获得 5 个并行进程。

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

有没有增加进程数的开关参数?

这就是我正在运行的:

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"}
         }
4

3 回答 3

0

我不确定您为什么要调用 PSSessionConfiguration。

如果您查看 New-PsWorkFlowSession 的帮助输出,您可能会看到一些看起来更接近您想要做的示例。我没有您用来测试此工作流程的模块,因此无法提供更多帮助。

于 2012-10-20T11:18:12.317 回答
0

这应该可以工作,您甚至不需要更改 PSSessionConfiguration。这是一个示例,因为我们没有您的模块。

Workflow Get-ParallelChildItem
{
        Parallel {
        InlineScript {gci C:\ -Recurse}
        InlineScript {gci C:\ -Recurse}
        }
}
于 2012-10-29T13:39:48.707 回答
0

来自 MSDN 论坛的 jrv提供了一个工作代码示例

$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}
于 2017-06-27T16:20:25.220 回答