This PowerShell script automatically manages the running state of specific Hyper‑V virtual machines based on a defined work schedule.
It ensures that the listed VMs are running during business hours (Monday–Friday, 08:00–17:00) and stopped outside of those hours — with one important exception:
If a VM is manually started outside the scheduled period (e.g., via Hyper‑V Manager or another PowerShell session), the script will detect this and keep it running until the next scheduled start period. This prevents unwanted shutdowns of manually started VMs.
The script also:
- Logs all actions to the Windows Event Log (
Application
log, source:HyperV-AutoControl
).