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 ...
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\lo
g'+((Get-Date). ToString("yyyy_ MM_dd"))+'.txt' ) an result is: log2016_03_23.t xt (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 FileSystemWatch
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.
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?
This is an amazing script.
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/updati
ng/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.
can it monitor files inside the sub-folder of the root path?
please disregard my question above .. just tested it and works. great script - thank you!
Hi, your script is great. I ask to you if it's possible enable it permanent or as service. thank a lot
No, unfortunately it is a script, and as such, must be running all the time. You could write a service in C#, using the same FilesystemWatch
PowerGUI ( http://powergui
.org/index.jspa ) very successfully compiled my modified version of this script to an exe, there is also an option to compile to service but I have not properly tested it yet. It might work for you. PS, thanks to Big Teddy for the useful code!
I agree, this script is great! I compiled the script as a service but it no longer works. I do have to be logged on. Any other ideas out there? Thanks!
you can do that by : 1- create a batch file "filesystemwatc
her.bat" 2- the contents of this batch will be : C:\Windows\Syst em32\WindowsPow erShell\v1.0\po wershell.exe -noexit -file "path to your ps script" 3- add this batch to the startup scripts of the server's local policy . or you can use a group policy . gpedit.msc -> computer configuration -> windows settings -> scripts (startup /shutdown) -> startup 4- after restarting the server , the powershell script will run in the background . that is ALL .
Hi Bigteddy - first of all thanks for the nice script! I have a question though: I'm trying to do a Copy-Item action upon triggering of an event but this stops after one or just a few copy actions. If I leave the Copy-Item out and just use the Write-Host everything is fine. I've done the same with the 'Created' event and that seems to be working ok. Any Ideas?