Parsing Text-Based Log Files

by Jun 3, 2011

Extracting useful information from huge text-based log files isn’t necessarily  a difficult task. Check out this line:

PS> Get-Content $env:windir\windowsupdate.log -Encoding UTF8 |
Where-Object { $_ -like '*successfully installed*' } |
ForEach-Object { ($_ -split ': ')[-1]}

As such, it reads the windowsupdate.log file and then takes all lines that contain the keyword "successfully installed," splits the line by ": " and picks the last element – which happens to be the product name of installed updates.

 

Twitter This Tip!
ReTweet this Tip!