Invoke-Parallel
Invoke-Parallel copied to clipboard
Adding item to external collection
It seems like it's not possible to add items to an external collection.
Example:
`$List = New-Object System.Collections.Generic.List[System.Object]
$1..100 | Invoke-Parallel -ScriptBlock { $item = $_ * 15 $List += $item }`
works as designed, Alternatie could be:
$List = @()
$List += $1..100 | Invoke-Parallel -ScriptBlock {
$item = $_ * 15
return $item
}