Forum Discussion

CHILLimECK's avatar
CHILLimECK
Copper Contributor
Dec 12, 2018

Powershell Parsing loggfile

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?

 

  • JoP_SG's avatar
    JoP_SG
    Copper Contributor

    Hello,
    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)

    • CHILLimECK's avatar
      CHILLimECK
      Copper Contributor

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

Resources