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,403 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,139 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 45,111 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?