Jump to content

Workstation Reboot with Prompts (48h deferral)

Recommended Posts

As the title implies, this is a script I created to prompt users to reboot. It allows them to defer for 4 hours at a time for a total of 48 hours (this can all be adjusted in the script), and then gives the user a warning that the PC is about to be restarted to finish installing updates, and that they have 5 minutes to save their work. Again, this is adjustable in the script. I used script math to increment a variable named @count@ every time the script is run, and to skip to the final message when @count@ >= 12. 

The script also checks for the agent's uptime, to ensure that the user isn't forced to reboot if they manually restart their PC after the final warning, but before the 5 minute sleep timer can expire. 

To use this, I've created a group called Uptime >= 14 Days. This group uses an auto-search I created to automatically add machines that meet the criteria (uptime >= 14 days, not a server) and is limited by the search. That way, machines that are rebooted are automatically removed from the group, as their uptime no longer reports >= 14 days. This reboot script is then scheduled to run against that group every two days at 8am in the morning. I set it up for every 2 days, rather than every 1, in the hopes that it would ensure the script isn't run a second time before the first one can finish. Also, I'm not concerned about a PC being up an extra day or two, as long as it is getting rebooted about every 14 days. 

I am no scripting guru, so I'm sure this can be improved upon. Still, I hope this is useful to someone. 

Workstation Reboot with Prompts (48h deferral)).xml

Edited by koticus
Added info

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...