we want monitor file activity on 1 of shared folders on our server.
$folder = 'd:\mysharedfolder'
planning use filesystemwatcher , log activities new, change & delete text file.
$fsw = new-object io.filesystemwatcher $folder, $filter -property @{includesubdirectories = $true;notifyfilter = [io.notifyfilters]'filename, lastwrite'} register-objectevent $fsw created -sourceidentifier filecreated -action { $name = $event.sourceeventargs.name $changetype = $event.sourceeventargs.changetype $timestamp = $event.timegenerated write-host "the file '$name' $changetype @ $timestamp" -fore green out-file -filepath d:\reports\phx_new.txt -append -inputobject "the file '$name' $changetype @ $timestamp" }
we want run monitoring between 0800 1800 (business hours)
- we want break monitoring log files, file huge if monitoring left running day saving single file.
- we plan run in 15 minutes interval, in hour's time should @ least 4 log files.
thank in advance.
for can make script configurations want , @ end invoke script run on configured intervals.
Comments
Post a Comment