Set-OctopusVariable can't handle object arrays?

Is Set-OctopusVariable not able to handle object arrays?

I’ve been able to pass DateTime PowerShell objects between steps, so I’m surprised object arrays won’t work.

I have two PowerShell steps. The first sets an octopus variable for an object array. The second attempts to read the array.

Set-OctopusVariable -name “myArray” -value $myArray

$myArray = $OctopusParameters[“Octopus.Action[STEP1].Output.myArray”]
Write-Host “myArray: $myArray”

This outputs:
"myArray: "

Is there a way around this?

Hi @andrewralon

Thanks for getting in touch!

The bit of knowledge that I think you are missing here is that all Octopus variables are strings, which is why passing an array in isn’t working as you might expect. For this to work you would have to read out of the array and pass in a concatenated string of the array objects (which you could then reverse back to an array if required).

Any questions please let me know,


So Octopus variables are all strings? That makes sense now.

I am now joining the strings together with a separator, and then splitting it into an array in a later step.


No problems, happy to help :slight_smile:


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.