Why does foreach-object -Parallel work in console but not in Azure Runbook

Phil Davies 26 Reputation points
2021-07-14T11:18:28.947+00:00

I have really simple script and when I run in a console it works but when I run it in Azure Runbook Test Plan it fails, Why???????

Script:

(1..2) | foreach-object -Parallel {  
        write-output "I am here $($_)"  
    } -ThrottleLimit 2  

When I run in the console I get:
114611-working.png

But if I run in a Azure Runbook I get:

System.Management.Automation.ParameterBindingException: Parameter set cannot be resolved using the specified named parameters.  
   at System.Management.Automation.CmdletParameterBinderController.HandleRemainingArguments()  
   at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments)  
   at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)  
   at System.Management.Automation.CommandProcessor.BindCommandLineParameters()  
   at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)  
   at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)  
   at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)  
--- End of stack trace from previous location where exception was thrown ---  
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()  
   at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)  
   at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)  
   at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)  
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)  

114550-not-working.png

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,366 questions
Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. tbgangav-MSFT 10,426 Reputation points Moderator
    2021-07-14T13:54:37.553+00:00

    Hi @Phil Davies ,

    The reason it currently fails in Azure Automation sandbox environment is because Foreach-Object -Parallel command was introduced in powershell version 7 preview 3 but currently Azure Automation powershell environment runs on version 5.1.

    As informed here, support for Powershell 7.0 in Azure Automation would be towards CY21 Q4 timeframe. Post that, would be the support for next versions or preview versions.

    If interested, you may upvote this related feature request. In general, Azure feature team would check feasibility of a feature request, prioritize against existing feature backlog, add in roadmap as appropriate and would announce and/or update the related Azure document once a feature request is addressed.


0 additional answers

Sort by: Most helpful

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.