Powershell FileSystemWatcher

This script uses the .net FileSystemWatcher class to subscribe to 'create', 'change' and 'delete' events on files or folders in the NTFS filesystem.It can be used to monitor a folder or folders, and can be modified to perform any action upon the triggering of these events. 

 
 
 
 
 
4.6 Star
(27)
23,719 times
Add to favorites
Storage
12/8/2011
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • $watcher.IncludeSubdirectories = $true is not working
    1 Posts | Last post October 02, 2019
    • $watcher.IncludeSubdirectories = $true not working in windows server 2012 R2 .Can you plz help me
  • Meaning ?
    1 Posts | Last post March 22, 2019
    • Hi,
      
      Maybe a stupid question, but when this script is started, is it supposed to mean to check the specified folder continuously ? Because I start the script, create testfiles, but nothing happens.
      
      The only outcome I have is "The file '' was " when I start the script, and that's it.
      
      What am I doing wrong please ?
      
      Thank you very much,
  • I added variable in the Action Block and it does not run.
    1 Posts | Last post March 12, 2019
    • $timestring = $timteStamp.ToString("MM-dd-yyyy-HH_mm_ss") + $name 
      I would like to add the timestamp to the file name I am trying to copy to another folder. But when I try to use this the Event will not trigger.
  • Windows Server 2012 R2
    1 Posts | Last post December 07, 2018
    • Tested on Windows Server 2012 R2. It works!
  • How can I watch several Folders
    2 Posts | Last post November 21, 2018
    • Your Trigger is great but I would like to watch several Folders. Certain Scripts should be started by Arriving of a file within one of those Folders. Is it possible to use Case Statement within it? If yes Please make an example.
    • Hi Alex,
      
      There's an altered script that allows you to do it for multiple folders, see link below:
      
      https://gallery.technet.microsoft.com/scriptcenter/Powershell-FileSystemWatche-e5fa31dd
  • Server 2016
    4 Posts | Last post May 08, 2018
    • Hi 
      
      I have installed this script on a test server in a test domain, but it does not seem to be working. 
      
      Do I also need to get a GPO for logging read, write and delete of objects? 
      
      I also noticed that you have the original settings for logging plus an enhanced setting for logging, which should I use? 
      
      TIA
      
      Emil
    • Edited to add - have taken another shufty at the script, and changed subdirectory flag to $true
      
      Seems to be working, will monitor and shout out if not. 
      
      Thanks
    • It is working fine, thanks.
      
      What do I need to have it log the name of the (offending) user doing the changes? 
      
      TIA
      
      Emil
    • Why do this stop working if I close the PS window it is running in? 
  • Only works the first time?
    2 Posts | Last post April 27, 2018
    • Does anyone know why it's only monitoring the first change/delete/create then does not report any additional updates? My events were never unregistered in fact I will get an error if I try to re-register them since they are currently running.
    • I figured it out. I did not have the c:\scripts\filechange\ directory created already so it was erroring out while looking for this and interrupted further detection. You can either delete the out-file line or make sure that directory is created ahead of time.
  • monitor folders about no changes
    1 Posts | Last post March 14, 2018
    • Hi,
      
      I need to monitor folders about no changes for two hours and send an e-mail afterwards. I am not sure what to adjust in the script.
  • WinXP
    1 Posts | Last post January 26, 2018
    • I checked, it works on WinXP SP3 with PowerShell 2.0 .Net2.0SP1. Thank you!
  • File Owner or who changed it
    2 Posts | Last post October 11, 2017
    • I have been using this and works great, I just would like to know how to modify it to record the name of the user that changed the file. I am monitoring a fileshare. 
    • Did you ever find a way to add a user name to this?
1 - 10 of 29 Items