Why is my PowerShell FileSystemWatcher sometimes failing to copy files?

September 17, 2025 1 answer
Asked by CuriousCat123
Hey everyone! I've been working on a Powershell project to create a sort of in-game selfie kiosk with two computers running different games. The setup involves monitoring screenshot folders to copy images automatically, display them in a slideshow, and print them using a photo printer. I've set up multiple FileSystemWatcher instances to watch these folders, but I'm running into a problem. Specifically, the action that moves screenshots from the Cyberpunk folder to designated folders only works inconsistentlyโ€”while the other parts of the script run without fail. I've shared the code snippet I'm using, and I'm really hoping someone can help me find a workaround as I'm under time pressure. Thanks in advance!

Answers

TechyTurtle42
I see where youโ€™re coming from! Instead of managing multiple event handlers individually, consider combining your scripts into fewer handlers to handle similar actions. Sometimes order isnโ€™t guaranteed when you add several handlers, which might lead to the inconsistencies you're experiencing. Give that a shot and see if it helps!

CuriousCat123: Thanks for the tip! I did combine the handlers, but the issue persists. What do you think about replacing multiple "Register-ObjectEvent" commands with a single "Wait-Event"? Could that simplify things?

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions