I am parsing error log files across multiple servers and need to report on problem errors. The error log files should contain at least the following (known errors that are OK):
- ERROR Some error text
- ERROR Some more error text
- ERROR Here is more error text
What I need is a Select-String search pattern that includes all three text strings above:
$Search_Str_1 = "ERROR Some error text"
$Search_Str_2 = "ERROR Some more error text"
$Search_Str_3 = "ERROR Here is more error text"
$Search_Str_1, $Search_Str_2, and $Search_Str_3 are acceptable error strings and should not be reported if found in the error logs. However, if any additional error string is found that does not match any of the above search strings, then it should be reported as a bad error.
Example:
- ERROR Some error text
- ERROR Some more error text
- ERROR Here is more error text
- ERROR This is bad error text and should be reported
The 4th error line (and any other line that does not match search_str 1, 2, or 3) would need to be reported as bad.
Hypothetical code:
$ErrorLog = Get-ChildItem -Path $LOG_PATH -Include Error.log -Recurse | Select-String -notmatch ($Search_Str_1 -or $Search_Str_2 -or $Search_Str_3)
How would I do this?