I am trying to take a CSV file with over 10 million lines, extract the records I need, have them sorted, and save them to a new file. I have been successful in getting the exact results I need by piping the results of Get-Content to Select-String -Pattern
("$Val1", "$Val2"), but it's taking hours to accomplish, whereas the batch files we have been using take just a few minutes. Is there a way to use a higher -readcount with get-content before piping it to select-string? I have
tried the example below but I get an error for every line being read saying the path cannot be found because it does not exist; however, in the path listed in the error it shows the exact data I'm trying to pull. Any help would be greatly appreciated.
Get-Content $File -ReadCount 1000 | ForEach { Select-String -Path $_ -Pattern ("$Val1", "$Val2") } | Add-Content $OutputFile;