6 Replies Latest reply on May 12, 2020 9:10 AM by maverix7

    vRA / vRO 8.1 - Return an array from Powershell

    PhilaaS Lurker

      I'm trying to use the new native powershell in vro actions but struggling to get the right syntax to return an array. Below is the example code that I’m using:

      function Handler($context, $inputs) {

          $output=@()

          $output += "first string"

          $output += "second string"

      write-host "first element type is $($output[0].gettype().name)"

      write-host "second element type is $($output[1].gettype().name)"

      write-host "output type name is $($output.gettype().name)"

      write-host "output basetype name is $($output.gettype().basetype.name)"

          return $output

      }

       

      I have tried setting the return type to:

      1. string and checking the array box
      2. array and unchecking the array box
      3. array and checking the array box
      4. properties and checking the array box

       

      I always get an error that says "Not an Array".

       

      Would greatly appreciate help if anyone has managed to make it work.