Creating objects parallel in powershell workflow and adding it to an array
try this way:
workflow sample { $ans=@() $arr=@(1,2,3) foreach -parallel ($a in $arr){ $obj= New-Object -type PSObject -Property @{ Number = $a } $workflow:ans += $obj } $ans }sample | select -Property Number
Add-member
doesn't work so well in a workflow
probably due to object serialisation/deserialisation.