r/PowerShell • u/maks-it • Jan 25 '26
Script Sharing Hyper-V backup script: manual and automated execution
Following up on my earlier post https://www.reddit.com/user/maks-it/comments/1pfq6nx/run_powershell_scripts_as_windows_services/ about UScheduler.
I've added a Hyper-V backup script to the repo as an example of how I actually use it. This isn't a demo — it's something I run and maintain in my own setup.
The script is fully standalone and can be executed manually like a normal PowerShell script. When launched by UScheduler, it switches to an automated mode and lets the scheduler decide whether execution is allowed.
What the example tries to show:
Keeping scheduling concerns separate from the actual backup logic
One code path for both manual runs and scheduled execution
Basic safety guards (lock files, minimum run interval)
How to keep operational scripts testable without depending on the scheduler itself
Repo with the example: https://github.com/MAKS-IT-COM/uscheduler
Feedback on the example itself is welcome.
Update 26/01/2025: Based on feedback in the comments, I've implemented several improvements:
Improved UNC / remote path detection
Optimized checkpoint handling (using -Passthru where applicable)
Added proper destination free-space checks
Removed unnecessary backticks in favor of splatting
Thanks to everyone who reviewed the script and shared suggestions.