I am looking to require restarts based on certain conditions within our environment. Currently we deploy Windows Updates via WSUS, but do not enforce forced restarts (this has a long history due to the type of environment I work in). We are looking utilize Task Scheduler to run a PowerShell script that does as follows:
- Checks if the system has a pending reboot due to Windows Update installation.
- If it does, check the system uptime.
- If the uptime is over 15 days (or maybe 10), alert the user that their system will be rebooted within 5 days automatically if they do not do so themselves.
- Repeat the alert once a day until the forced restart time is hit.
I have no idea where to begin with this. I know how to make WMI calls for system uptime, but not for pending reboots. Is Powershell the best thing for something like this, or is there a third-party program that might be more effective?