Hey Guys, I have the following line in a txt file (log file)
2012-08-14 18:00:00 [ERROR] . Exception SQL error 1
2012-08-14 18:10:00 [ERROR] . Exception SQL error 2
2012-08-15 18:00:00 [INFO] . Started
- Check the most recent entry(s) the last 24 hours
- if there's an error [ERROR] write-out a statement that says (Critical) with the date-time of the error
- If there's no erros write-out (Ok)
So far I learned to write this much and would like to learn more from you:
$file = "C:\Users\example\Documents\Log.txt"
cat $file | Select-String "ERROR" -SimpleMatch