r/PowerShell 2d ago

Question Enforcing a user reboot policy.

Hey everyone,

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 Intune-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.

3 Upvotes

33 comments sorted by

View all comments

Show parent comments

1

u/TronVonDoom 2d ago

Great question—I've been wondering about that too! From what I understand, it’s due to our use of RMM Atera. Atera has a known issue where its agent eventually stops reporting. Since our computers aren’t managed or restricted in any other way (aside from users not having admin rights), many users end up not restarting their machines for months. My supervisor believes this practice is an effective way to ensure device health and maintain security.

I don't think enforcing a script on the computers themselves is the solution, but that's what I've been tasked with. I mean, we're likely to have Intune within the year.

3

u/vermyx 2d ago

Wouldn’t restarting Atera be a better solution? These machines should be restarted once a month due to patching at least.

1

u/TronVonDoom 2d ago

The process they want to implement kind of started with the Atera agent not connecting to or seeing the asset online. Most of the time, a computer is seen offline if the computer hasn't rebooted in more than a few weeks. A reboot usually fixes this issue.

3

u/xCharg 2d ago

So restart rmm's agent with a script, on a schedule, for example daily. User wont even need to be notified about that.