Monitor a directory with FileSystemWatcher
<p>I have a directory which is getting filled by some program. I would like to monitor this directory and check if files are continuously getting added to the directory. If for Example for 5 min no file is getting added to the direcotry I want to get notified. The Files are also getting deleted but i just have to care about the new files.<br>
The script would run for about 20 min every three hours.<br>
The code for the FileSystemWatcher:</p>

<pre><code>$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = "C:\temp\test"
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $true

$created = Register-ObjectEvent $watcher "Created" -Action {
   write-host "Created: $($eventArgs.FullPath)"
   Get-Date -Format "HH:mm:ss" | Out-File "C:\temp\log.txt" -Append
}
</code></pre>

<p>I don't know how i could achive this, and I'm thankful for every input.</p>