Ambitious Project - File tracking parsing logs

  • I have this idea for work that I can somehow parse existing log files that record the processing of files. There is an application that processes files and writes entries to a log file. Things like "file found", "processing file", "file name", "processed date/time". I want to use PowerShell to parse through these logs and if comes to "file found" read the next lines that correspond with that file processing and preferably write them to a table in a database or to another log for processing later. I am pretty familiar with how to write to a log file or table but not in how to use PowerShell to iterate through a log file parsing and writing output based off conditions.

    Has any one had experience in implementing PS in this type of way? Any helpful links or suggestions you can share?

    Thanks

    Sean

    A clever person solves a problem. A wise person avoids it. ~ Einstein
    select cast (0x5365616E204465596F756E67 as varchar(128))

  • Found this article/post that looks pretty close to my required needs.

    http://www.sqlservercentral.com/articles/powershell/73460/

    Anyone with others great links or comment on person experience please reply. Thanks!

    A clever person solves a problem. A wise person avoids it. ~ Einstein
    select cast (0x5365616E204465596F756E67 as varchar(128))

  • Take a look at Select-String's -context parameter.

    Here's an article with some examples: http://blogs.msdn.com/b/powershell/archive/2010/05/07/select-string-context.aspx

    - Jeff

  • Thanks Jeff! Briefly looked it over and looks like it has many nuggets of golden information to extract!

    A clever person solves a problem. A wise person avoids it. ~ Einstein
    select cast (0x5365616E204465596F756E67 as varchar(128))

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply