0
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

我得到的输出如下

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]

我无法更新我在函数和工作流之外声明的数组。

4

0 回答 0