I have a log file that appends a "restart successfully" line after each restart. Starting from the last "restart successfully" line, I want to find any lines after that contain a word from a list of search words.
How can I do this? I have partly working code below:
$contentsOfLog = Get-Content $inputFile
$keyWords = $contentsOfLog | Select-String 'restart successfully'
$linenumbers = $keyWords.LineNumber
$linenumber = $linenumbers[$linenumbers.Length - 1]
$inputLines = ""
For ($i=$linenumber; $i -lt $contentsOfLog.length; $i++) {
$line = $contentsOfLog[$i]
$line = $line|select-string -pattern $error|Out-String
$inputLines += $line.TrimEnd()
}