How to use ForEach-Object -Parallel in Azure Devops Pipeline Agent.

Ramakrishna Abhijeet P 70 Reputation points
2024-04-30T15:59:10.87+00:00

I want to use a PowerShell script which has below cmdlet. When I tried to use MS Hosted Pipeline agent with Parallel feature I'm getting "Parameter set cannot be resolved using the specified named parameters" error. How can I execute the script.

ForEach-Object -Parallel $scriptBlock
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,628 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,915 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 47,786 Reputation points
    2024-04-30T19:09:54.0966667+00:00

    The "-Parallel" parameter is present in PowerShell 7. It's not present in PowerShell 5. Which version of PowerShell are you using?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.