I have a script monitoring a log file with get-Content, and it expects new lines to be written so that it can detect the change. The registrar changes the name of the log file every day to make it System_ $ date.log.
I am trying to make my Get-Content wait for new lines, and also break when the date changes, and then repeat the execution with a new date in the file name. Does anyone know how to do this?
thanks
Edit
The script looks like this:
Get-Content System_201371.log -wait | where {$_ -match "some regex"} | foreach { send_email($_) }
The file name, which is System_201371, changes every day, it will be System_201372, etc. Also this script works as a service, I need to break it and re-execute with a new file name
source share