My code
[System.Collections.ArrayList]$Global:shells=@()
$cmdProc = Start-Process powershell -ArgumentList "-noexit", ("-command grunt "+ [string]$argList) -WorkingDirectory $fwd -PassThru
[System.Collections.ArrayList]$Global:shells.Add(($cmdProc))
does add a PowerShell process to $shells arrayList. But it also displays an error message:
cannot convert the "0" value of type "System.Int32" to type "System.Collections.ArrayList". At line:16 char:1 + [System.Collections.ArrayList]$Global:shells.Add(($cmdProc))
It is definitely related to index of arrayList it adds at, but what's going on? I can access $shells[0] just fine.