Powershell Parsing loggfile

Copper Contributor

Hello, i´m new to Powershell and need some help. 

I need to parse a logfile from a network licensemanager where 90% of the entries are denials. i wrote a script which works fine, but the time it needs is too much.

There are about 250k lines in the inputfile, at ~40k lines the time increments dramaticaly so that the time the script needs rise up to 30mins. 

Someone have an idea how could i change my very simple code that it runs much faster?

2018-12-12 09_59_36-Windows PowerShell ISE.png


2 Replies

I would just filter the lines with a match and use the pipeline to write it out to a file.
This should be faster:
get-content "$Path\lmgrd.log" | Where-Object { if ($_ -notmatch "DENIED:") { $_ }} | Out-File ($path+$fileName)

Thanks, this solution works fine and much faster than my one.