Powershell can parallel threads update the same array
$logNames.count
10
Measure-Command {
$logs = $logNames | ForEach-Object -Parallel {
Get-WinEvent -LogName $_ -MaxEvents 5000 2>$null
} -ThrottleLimit 10
}
TotalMilliseconds : 115994.3 (1 minute 56 seconds)
$logs.Count
50000
Measure-Command {
$logs = $logNames | ForEach-Object {
Get-WinEvent -LogName $_ -MaxEvents 5000 2>$null
}
}
TotalMilliseconds : 229768.2364 (3 minutes 50 seconds)
$logs.Count
50000