When you use Get-Content to read in text files, you may initially be disappointed by its performance. However, Get-Content is slow only because it emits each line to the pipeline as it reads the file, which is time-consuming. You can dramatically speed up reading large text files by adding the parameter -ReadCount 0 to Get-Content. This way, the file is read and only then passed on to the pipeline. Check this out:
Get-Content $env:windir\windowsupdate.log |
Where-Object { $_ -like '*successfully installed*' }
$txt = Get-Content $env:windir\windowsupdate.log -ReadCount 0
$txt | Where-Object { $_ -like '*successfully installed*' }
$txt | Where-Object { $_ -like '*successfully installed*' }