There is a Microsoft .NET Framework class library called FileSystemWatcher.
This class monitors file related events like Create, Rename, Delete and run any action that you specify.
Following example is FileSystemWatcher notifying when *.DV* files under the C:\EVStorage folder were created or deleted.
This is how to do it.
$FileWatch = New-Object System.IO.FileSystemWatcher $FileWatch.Path = "C:\EVStorage" $FileWatch.Filter = "*.DV*" $FileWatch.IncludeSubdirectories = $true $FileWatch.EnableRaisingEvents = $true Register-ObjectEvent $FileWatch "Created" -Action { Write-Host -ForegroundColor yellow (get-date -Format "yyyy/MM/dd HH:mm:ss") "[Created] [$($eventArgs.Name)]"} Register-ObjectEvent $FileWatch "Deleted" -Action { Write-Host -ForegroundColor red (get-date -Format "yyyy/MM/dd HH:mm:ss") "[Deleted] [$($eventArgs.Name)]"} Register-ObjectEvent $FileWatch "Renamed" -Action { Write-Host -ForegroundColor white (get-date -Format "yyyy/MM/dd HH:mm:ss") "[Renamed] [$($eventArgs.Name)]"}
Unfortunately, each event does not contain process information so there is no way to tell which process created or deleted the files.
To understand which process accessed the files, Process Monitor is the tool to use.
FileSystemWatcher class can be used as a “light” real time monitoring tool to see if any archived files are created.
Use cases are..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.