title: monitor a log file with Get-Content -wait until the end of the day
body: <p>I have a script monitoring a log file with get-Content and it waits for new lines to be written so it can detect the change. The logger changes the name of the log file every day to make it System_$date.log. </p>
  
  <p>I am trying to make my Get-Content to wait for new lines as well as break when the date changes then to re execute itself with the new date in the filename. Does anybody have an idea how this could be done?</p>
  
  <p>Thanks</p>
  
  <p><strong>Edit</strong></p>
  
  <p>The script looks like this:</p>
  
  <pre><code>Get-Content System_201371.log -wait | where {$_ -match "some regex"} | 
  foreach {   
     send_email($_)
  }
  </code></pre>
  
  <p>The file name which is System_201371 changes everyday, it will be System_201372 and so on, Also this script runs as service, I need to it to break and re-execute itself with a new filename</p>