question

PhilDavies-0096 avatar image
0 Votes"
PhilDavies-0096 asked PhilDavies-0096 commented

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

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


windows-server-powershellazure-automation
working.png (31.5 KiB)
not-working.png (175.9 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

tbgangav-MSFT avatar image
0 Votes"
tbgangav-MSFT answered PhilDavies-0096 commented

Hi @PhilDavies-0096,

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.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ah I thought for some reason that it was already supporting version 7, bummer will be upvoting the request!

1 Vote 1 ·