When using powershell and following this article running the following example throws an error.
Example:
1..5 | ForEach-Object -Parallel { "Hello $_"; sleep 1; } -ThrottleLimit 5
Error:
ForEach-Object : Parameter set cannot be resolved using the specified named parameters.
Removing the body of the loop does not resolve the issue. It is present whenever using the -Parallel keyword.
The article is from last year which makes me think the feature must still be present in powershell. Am I missing something obvious here?
I ran into this issue when trying to test the script in the Windows Powershell ISE script editor, despite pwsh --version telling me that it was 7.2.0.
As Owain Esau points out in the comments, the error is telling you that the current version of ForEach-Object does not support the -Parallel parameter.
But if you open run your script in a dedicated Powershell 7 window, it should execute just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With