Q: I'm trying to return an array of objects from within Windows PowerShell in a System Center Orchestrator Run .Net script and publish it to a data bus--so why aren't I getting the data I expect?
A: The Run .Net script activity will return data in a way you might not expect. Consider the following PowerShell script that you might run in a regular PowerShell window:
You would receive the labels of all the Azure virtual machine (VM) images into the $vmimages variable. If you ran this within an Orchestrator Run .Net script activity and published the variable to the data bus, you would see a publishing of the type of the returned data rather than the data itself.
The first step is to not use format-table (ft) but instead use this:
Next, you need to create your own custom array and add the data into that custom array. Then the custom array (vmArray) is published to the data bus, which will have the actual values. For example:
foreach ($image in $vmimages)
$vmArray += $image
Thanks to Charles Joy for helping me out with this one!