How Can I Set Up a User Reboot Policy with PowerShell on Windows 10/11?

0
0
Asked By CleverPigeon42 On

Hey everyone! I'm working on a PowerShell solution for Windows 10/11 that sets up scheduled tasks to manage system restarts based on how long the system has been running. Here's my plan:

- **Wednesday at 4:00 PM:** The script should check if the computer has been up for 5 days or more and notify the user about our 7-day reboot policy, which mandates a restart on Friday at 10:00 PM. If the user is not logged in at that time, the notification should be stored and displayed the next time they log on.
- **Friday at 9:30 PM:** The script should check if the uptime is 7 days or more and then warn the user with a popup that the computer will restart in 30 minutes at 10:00 PM, allowing them time to save their work. After the warning, the computer should initiate a restart after the 30-minute delay.
- **Logon Notification:** Any scheduled notifications that were missed due to the user not being logged in should be displayed when they next log on.

I'm particularly struggling with ensuring the logic works correctly to avoid any accidental boot loops or unexpected restarts. Has anyone done something similar or have any tips for best practices? Any sample scripts or advice would be super helpful! Thanks!

2 Answers

Answered By SkepticalDev On

To prevent boot loops, just check the uptime before initiating any reboots. If it's less than 1 day, there’s no need to reboot. Otherwise, go ahead. Keeping it simple helps avoid unnecessary issues!

Answered By CuriousTechie99 On

You can simplify your approach by using Task Scheduler for your reboot policy. Here's what I'd suggest:

1. Set a task to check uptime at your specified times and trigger notifications. Run it only when users are logged in, and enable the option ‘Run task as soon as possible after a scheduled start is missed’.
2. For issuing warnings, your script can check the uptime and use the command `shutdown /r /t 1800` to warn users of the 30-minute delay before rebooting. You can also add a custom message using the `/c` flag.

This way, you can manage the notifications without it getting too complicated!

HelpfulHacker88 -

I like this method! It’s a straightforward way to manage notifications and avoid complications. Just remember to double-check the uptime condition before the reboot!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.