Powershell: What is the max. Value for Throttlelimit of Foreach-Object -Parallel?

1.7k views Asked by At

I have 1 Million Items to check with Powershell. To improve the performance, I want to use ForEach-Object -Parallel. For this reason, I have deployed a very powerful VM.

Docs: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/foreach-object?view=powershell-7.2#description

The runspace pool size is specified by the ThrottleLimit parameter. The default runspace pool size is 5. You can still create a new runspace for each iteration using the UseNewRunspace switch.

I notice that no matter how high I set the limit, the CPU usage does not increase. Is there a technical maximum limit for this parameter? I have the impression that above a certain value the limit is simply capped.

$oneMillionItems | ForEach-Object -Parallel {
        Do something ...
} -Throttlelimit 300

enter image description here

PS > $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Microsoft Windows 10.0.20348
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
0

There are 0 answers