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
17,125 times
Add to favorites
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question

  • monitor folders about no changes
    1 Posts | Last post Wed 2:47 PM
    • 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 10, 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?
  • File Change always comes twice !!!
    1 Posts | Last post March 24, 2016
    • now is every day just ne new log file created yyyy_MM_dd.txt fit only change problem I have yet. !! the create (file is box folder XML) is green written an entry and additional 2x change what I want !!! when I change the file in the folder XML should there be change message which comes but twice !! if I file delete as desired only 1x red message delete reported! that's OK.
      I do not want is to create the change message in and not always 2 times .. written somewhere too much I think ...
  • Hi, how do I get the script to run automatically?
    2 Posts | Last post March 23, 2016
    • I would like that if an xml file comes in, automatically log.txt is created! currently I need to start powershell manually to create a log.txt
      my script:
      Get-ChildItem -Path 'D:\Kemal test xml\XML' | SELECT CreationTime, name | Format-Table -AutoSize | Out-File -filepath ('D:\Kemal test xml\Logfiles\log'+((Get-Date).ToString("yyyy_MM_dd"))+'.txt')
      an result is:
      log2016_03_23.txt (text Document)
    • now everyone is entry 3 times written to the log.txt! 2x change and 1x create ...
      it should make only 1x create or 1x change or 1x delete ...!!
      plz help!! 
      i use the script FileSystemWatcher!
  • How to add a file move / rename
    1 Posts | Last post November 23, 2015
    • Thank you for your script, I'm wondering how I could add one piece of functionality to it, 
      When the file created goes off, that it would copy to another directory, and rename the existing file to yyyyMMdd format. 
      I don't know where to put that in, or if I just need to create something new? I love the script though and it's working flawlessly for updating that things are changing. 
      Thank you. 
  • new folders within folders
    1 Posts | Last post November 10, 2015
    • Hi.
      If I create new folders within the watched folder, it doesn't keep track of any new files.
      Is this expected or am I doing something wrong?
  • Awesome Script
    1 Posts | Last post September 03, 2015
    • This is an amazing script.
  • Run as service/batch file
    1 Posts | Last post September 03, 2015
    • I have modified the script to my liking and now I try to run it as a service or start it using a batch file. Both do not work. When running as a service and creating/updating/deleting a file the service stops. No files are logged. When running as batch file only 1 item is logged. After the first file nothing gets logged.
      Any ideas on how to run this script in batch or as a service?
  • How to monitor by excluding a few files in a folder.
    1 Posts | Last post July 20, 2015
    • How to monitor by excluding a few files in a folder.
1 - 10 of 22 Items