I'm trying to put together a Windows 10/11 PowerShell solution that sets up a few scheduled tasks to manage system restarts based on uptime, and I'm running into some design challenges—especially around avoiding boot loops. Here's what I'm aiming for:
Wednesday at 4:00 PM: The script should check if the computer's uptime is 5 days or more. If it is, it should pop up a notification warning the user of our 7 day reboot policy that is enforced to restart on Friday at 10:00 PM. If the user isn’t around at that time, the notification needs to be saved so that it can be displayed at the next logon.
Friday at 9:30 PM: The script should check again, and if the uptime is 7 days or more, it should warn the user (with a popup) that the computer will restart in 30 minutes at 10:00 PM, giving them time to save their work. After the warning, it should initiate a restart (with a 30-minute delay).
Logon Notification: If any scheduled notifications were missed because the user wasn’t logged in, the script should display the saved message when the user next logs on.
Additional context:
We're about to move over to an -managed environment, but my supervisor wants this solution up and running before the switch happens.
The part I'm really struggling with is making sure the logic works correctly without accidentally triggering a boot loop or causing any unintended restart behavior. Has anyone tackled a similar project or have suggestions for best practices on how to avoid these pitfalls?
Any ideas, advice, or even sample scripts that might point me in the right direction would be greatly appreciated!
Thanks in advance.
Assistant
Here’s a well-structured approach to implementing yourWindows 10/11 reboot policyusingPowerShellandScheduled Tasks, while avoiding boot loops and unintended restart behaviors.
Design Considerations
Avoiding that the restart task only triggers if the uptime is≥ 7 days.Use registry flags or event logs to track whether a restart was recently enforced.
Ensure that the restart task only triggers if the uptime is≥ 7 days.
Use registry flags or event logs to track whether a restart was recently enforced.
Persisting Notifications Across LoginsSave pending notifications in the registry (e.g.,HKCU:\Software\RebootPolicy).Display them at login if the user missed the previous warning.
Save pending notifications in the registry (e.g.,HKCU:\Software\RebootPolicy).
Display them at login if the user missed the previous warning.
User Notification HandlingUsemsg.exeor a PowerShell toast notification for user warnings.Ensure user warnings areinteractive, even if the session is locked.
Usemsg.exeor a PowerShell toast notification for user warnings.
Ensure user warnings areinteractive, even if the session is locked.
Avoiding Boot Loops
Ensure that the restart task only triggers if the uptime is≥ 7 days.
Use registry flags or event logs to track whether a restart was recently enforced.
Ensure that the restart task only triggers if the uptime is≥ 7 days.
Use registry flags or event logs to track whether a restart was recently enforced.
Persisting
Save pending notifications in the registry (e.g.,HKCU:\Software\RebootPolicy).
Display them at login if the user missed the previous warning.
Save pending notifications in the registry (e.g.,HKCU:\Software\RebootPolicy).
Display them at login if the user missed the previous warning.
User Notification Handling
Usemsg.exeor a PowerShell toast notification for user warnings.
Ensure user warnings areinteractive, even if the session is locked.
Usemsg.exeor a PowerShell toast notification for user warnings.
Ensure user warnings areinteractive, even if the session is locked.
if (rebootWarning) {
message = "Reminder: Your computer was scheduled for restart. If it hasn't restarted, please do so manually."
New-BurntToastNotification -Text "Missed Restart Warning", $message
code
# Clear flag after showing notification
Remove-ItemProperty -Path "HKCU:\Software\RebootPolicy" -Name "PendingRebootWarning" -ErrorAction SilentlyContinue
}
if (rebootEnforced) {
message = "Your system was restarted due to the 7-day uptime policy."
New-BurntToastNotification -Text "Restart Completed", $message
code
# Clear flag after showing notification
Remove-ItemProperty -Path "HKCU:\Software\RebootPolicy" -Name "PendingReboot" -ErrorAction SilentlyContinue
The script only triggers a restart if uptime is≥ 7 days.
After restart, registry flags arecleared on next login.
The script only triggers a restart if uptime is≥ 7 days.
After restart, registry flags arecleared on next login.
✅Persists Missed Notifications
Storeswarnings in the registryand displays themon next login.
Storeswarnings in the registryand displays themon next login.
✅Non-Intrusive for Users
Gives usersWednesday and Friday warningsbefore enforcing the restart.
Gives usersWednesday and Friday warningsbefore enforcing the restart.
✅Works in Intune Environments
You can push this viaIntune PowerShell scripts or GPObefore migrating.
You can push this viaIntune PowerShell scripts or GPObefore migrating.
Let me know if you need tweaks!
Cite this conversation
“Enforcing a user reboot policy. Hey everyone, I'm trying to put together a Windows 10/11….” Conversation with ChatGPT (version unspecified), from the ShareChat — Chatbot Conversations in the Wild dataset. The Chat Archive, 2026. https://thechatarchive.com/c/01m84ts86g9p84t28n4qba7t84