Unregister a registered filewatcher event does not work


I want to watch a folder with powershell and I am a PS beginner.

That script works ONE time when I start the script.

But when I have to restart the script again because I changed some script code I get this error message:

I tried:

this at the top of the script:

does not work.

How do I correctly unregister the event so I can run my script as often I want and the previously registered event is disposed?



Ok, looking at what your trying to achieve… to answer your original question, you need to do the following to unregistered the event.

I have to ask why are you having to make 1000 adjustments to the code. If you are trying to register 1000 different events to be monitored it would make more sense to loop and increment a variable using the ++ modifier.

I have achieved this already if this is what your tying to accomplish and can share some code if you need it.


Unregister a registered filewatcher event does not work by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply