I need to create a PowerShell script that watches a specific folder and automatically prints each new file whenever it is added. After printing, the file should be moved to another folder so it is not processed again. Is this possible with standard Windows tools, and would a FileSystemWatcher or a scheduled task be the better approach?
4 Answers
For a simple polling script, enumerate the files and process them one at a time. Don’t pipe Start-Process directly into Remove-Item: printing is usually asynchronous, so the file may be moved or deleted before the print job has actually started. Use the printer’s Print or PrintTo shell verb, wait for the file to be ready, and only move it after the print operation succeeds.
A scheduled task is easier if you want to avoid .NET event handling. Run a PowerShell script every few minutes, find files in the input folder, print them, and then move successfully processed files into an archive or completed folder. Keep a log or move the files afterward so they aren’t printed repeatedly.
The most direct approach is to use .NET’s [System.IO.FileSystemWatcher] through PowerShell. Watch the folder’s Created event, then run the print command for the new file. You’ll probably want to wait briefly and confirm the file is no longer being copied before printing, since the event can fire while the file is still incomplete.
A WMI or CIM event subscription can also be used, but FileSystemWatcher is usually simpler for a script that only needs to monitor one folder.
A third-party utility such as PrintFile can watch a folder and send new files to a selected printer, which may be easier than maintaining a custom script. Whichever method you choose, the printer needs to be installed and available on the machine running the watcher, and the files should be moved to a separate folder after successful processing.

You can also configure Task Scheduler to react to file-creation auditing events, but periodic polling is generally easier to maintain.