Azure Automation differences with PS7 and PS5 runbook using an array parameter value on Hybrid

Jesus Chao 141 Reputation points
2024-08-27T16:04:52.4066667+00:00

I have an open ticket with Microsoft concerning this issue but I am currently stuck with 1st level support and a lack of understanding on what my issue is. I was hoping maybe the community could help me with this.

We have a few runbooks that use the PARAM() statement so that you can feed the runbook parameters for each situation. When starting the runbook using the start-azautomationrunbook cmdlet, if I used an array as a parameter, the runbook would treat that parameter as an array as we would expect using the PS5 environment.

However, recently we have been moving our runbooks to the PS7 Environment and we have noticed that when using the same code, any time we use an array in the exact same runbook results in the parameter being changed to a string value. I am curious if anyone else is running into the same issue. This appears to be only happening in Hybrid.

To test, create a runbook in the PS7 environment and use the following as your first line of code:

PARAM($receivingvariable)
#Output Variable Type
$receivingvariable.gettype().fullname
$receivingvariable[0]
$receivingvariable[1]

Then launch the new runbook using start-azautomationrunbook using Hybrid

$array = @("FirstItem","SecondItem")
start-azautomationrunbook -name <NameofRunbook> -automationaccountname <automationaccountname> -resourcegroupname <nameofresourcegroup> -parameters @{'receivingvariable' = $array} -runon <hybridworkergroup>

Then look at the results of the runbook job and if the output is string or object. Then change the runbook to use PS5 environment and try again. See if the result is System.Object

PS7:

User's image

PS5:

User's image

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,256 questions
{count} votes

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.