Parsing Text-Based Log Files – Faster!

by Jun 6, 2011

In a previous tip, we showed you how to parse text-based log files using the PowerShell pipeline. However, the pipeline has considerable overhead. Without the pipeline approach, you can get the same results about 10-times faster:

foreach($line in (Get-Content $env:windir\windowsupdate.log `
-ReadCount 0 -Encoding UTF8)) `
{ if ($line -like '*successfully installed*') `
{ ($line -split ': ')[-1]}}

 

Twitter This Tip!
ReTweet this Tip!