T13nn3s / Get-ContentFromLogFiles

Powershell function for monitoring LogFiles

Repository from Github https://github.comT13nn3s/Get-ContentFromLogFilesRepository from Github https://github.comT13nn3s/Get-ContentFromLogFiles

Get-ContentFromLogFiles

Check multiple log files for specific words or sentences and creates a new entry in the Event Viewer. After running the script it will start recursively for LogFiles with a .log extension. After finding the SearchString it will log a warning in the Application log(EventID 10998). When the script does not find the specified search word/sentence it will create an Information Entry in the Event Viewer(EventID 10999).

How to use

First, you need to import this function into your Powershell session.

Import-Module .\Get-ContentFromLogFiles

Now you're ready to use this function.

Get-ContentFromLogFiles -LogFolderPath C:\Folder -SearchString failed

With this script, you do not have to monitor the logfiles by yourself for an error. When this script finds an error in the logfiles it will create a warning in the Event Viewer.

When the specified word/sentence is found:

EventID: 10998 Logname: Application EntryType: Warning Source: CheckLogFiles Message: The word/sentence '$SearchString' found in the LogFiles in $LogFolderPath.nnLogFiles: $results.

When the script cannot found the word/sentence specified:

EventID: 10999 Logname: Application EntryType: Information Source: CheckLogFiles Message: The word/sentence '$SearchString' not found in the LogFiles in $LogFolderPath.

Changelog

[1.0] 3 April 2018

Initial creation

About

Powershell function for monitoring LogFiles


Languages

Language:PowerShell 100.0%