Registered fine and never fired once. Three faults, all found on the win11 VM. A `-Once -At (Get-Date)` trigger does NOT run immediately: its first run is the start boundary PLUS the repetition interval, 15 minutes out. This ships as a DetectionMethod=Always entry, so it ran every enforce cycle, 5 minutes apart, and each Register-ScheduledTask -Force reset the start boundary to "now" - pushing the first run back to +15 before the previous +15 could elapse. 5 < 15, so the task sat Ready at LastTaskResult 267011 (SCHED_S_TASK_HAS_NOT_RUN) forever. It now registers only when the task is missing or its arguments changed, and starts it once on first registration rather than waiting out the first interval. A bay provisioned by the broken version carries a task with correct arguments that has never run, so "leave it alone if it matches" would have stranded exactly the machines that hit the bug. If the task has never run it is kicked once; after that LastRunTime is set and the check is a no-op. None of this was visible. The engine records only "ps1: <path>" and an exit code for a PS1 entry, so Write-Host reached nothing, and with the fail-safe `exit 0` on every path a silent early-out was indistinguishable from success. It now also writes C:\Logs\Shopfloor\shadow-setup-<date>.log. Scope is no longer hardcoded either: this script is shipped by more than one scope now, and a wrong value would shadow the wrong manifest silently. It is derived from the script's own directory, the same way the share manifest path already was, so the two cannot disagree.
6.8 KiB
6.8 KiB