title: Run Powershell script as a service, watching log files and reporting via email
body: <p>I have some log files that I am watching, I need to do this using PowerShell since its a windows server. the command I am using to do this is:</p>
  
  <pre><code>Get-Content System.log -wait | {$_-match "some regex"}
  </code></pre>
  
  <p>I am trying to run this in a script and make it email me if it found any changes to the log file that follow the regex i specify. This is easily doable using bash and cron. I am not sure what's the equivalent in PowerShell. and what return code I need to look for to know if it found anything?</p>