I have 265 CSV files with over 4 million total records (lines), and need to do a search and replace in all the CSV files. I have a snippet of my PowerShell code below that does
I see this a lot:
$content | foreach {$_ -replace $SearchStr, $ReplaceStr}
The -replace operator will handle an entire array at once:
$content -replace $SearchStr, $ReplaceStr
and do it a lot faster than iterating through one element at a time. I suspect doing that may get you closer to an apples-to-apples comparison.