Update global variable from workflow

399 Views Asked by At
function function1(){
    Param($a)    
    "YOU HAVE entered : $a"
    $arr+=$a    
    $arr2.Add($a)
}

workflow wf{
    Param($b)
    Parallel{
        sequence{
            function1 $b
        }
    }
}

$arr = @()
$arr2 = [System.Collections.Arraylist]@()
wf -b 10
$arr
$arr2

The output I am getting as below

YOU HAVE entered : 10

Microsoft.PowerShell.Utility\Write-Error : You cannot call a method on a null-valued expression.
At wf:12 char:12
+ 
    + CategoryInfo          : NotSpecified: (:) [Write-Error], RemoteException
    + FullyQualifiedErrorId : System.Management.Automation.RemoteException,Microsoft.PowerShell.Commands.WriteErrorCommand
    + PSComputerName        : [localhost]

I am unable to update both the arrays which I declared outside the function and workflow.

0

There are 0 best solutions below