Script automatically pauses after some time

Hi all

I’ve written a powershell script that watches a specific directory. Once a file was placed in that directory it gets uploaded somewhere else by the script.
I’ve noticed that after a few hours the script somehow goes into “idle” state and doesn’t keep watching the folder anymore until I press any key. Then the script continious doing its job again.

This is very annyoing as the script needs to be awake 24/7.
Anyone has an idea why this happens? Btw. the script ist started via Windows Task Scheduler, the scheduler logs show that the task was in “running” state all the time so I think it couldn’t have been causing the “idle” state of the script.

Any help would be much appreciated.

First off, it’s basically impossible for anyone to help troubleshoot a script without seeing the script itself. Imagine trying to fix a car engine without being able to look inside of it.

Secondly, assuming you’re using FileSystemWatcher, I think postanote’s answer in this thread may help you.