Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Parsing Log file with PowerShell

$
0
0

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



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>