Workflow MaxSessionsPerWorkflow

How can I increase the sessions in a PS 5.1 Workflow? I’ve tried setting the max to 10 using this

$wfopt = New-PSWorkflowExecutionOption -MaxSessionsPerWorkflow 10 -MaxDisconnectedSessions 200
Register-PSSessionConfiguration -Name sqldba -SessionTypeOption $wfopt -Force

and then in the command referencing the session like this

Run-UpdateStats -PSConfigurationName sqldba -SqlServers $Workload

 

But still only 5 sessions.

Am I doing something wrong?

See if there is any parameter which limits the concurrent sessions, such parameter normally has the name -ThrottleLimit

Yes there is, and it’s set to 10

foreach -parallel -throttlelimit 10 ($SqlServer in $SqlServers)

 

 

I’ve gone down another path, rather than using a WorkFlow, I’m using a RunSpace and that’s working nicely for me.

I found this article helpfull: Multithreading In PowerShell - Running A Specific Number Of Threads | xkln.net