6 Replies Latest reply on Jun 30, 2017 11:13 AM by dsears

    Force reboot after certain uptime?

    jwood8 Apprentice

      Hi all,


      We have a number of users who never reboot their machines, this can cause issues with patches needing reboots. We don't really want to force reboots at the time of patching, but we do want to set it up so if you haven't rebooted in say 7 days you get prompted to do so with a countdown timer.


      Is there a way to do this? I know you can schedule a reboot at a certain time but that's not what we need.



        • 1. Re: Force reboot after certain uptime?
          Markus.Gonser ITSMMVPGroup

          Hi jwood8,


          which version of LDMS do you use?


          best regards


          • 2. Re: Force reboot after certain uptime?
            phoffmann SupportEmployee

            One way to consider doing it is using Local Scheduler to kick off a local batch / powershell script.


            Check for the amount of "uptime" that the system has had, and if need be throw the user a prompt ... or inculde reboot options for the end-user with a maximum delay incorporated (so 3x delay of 1 day" for instance) ...


            Other companies flat-out "shutdown / reboot" machines on a Friday evening / Saturday (and TELL their users this) so that weekly reboots DO happen.


            There's a few ways you can tackle this one - user education & comms is something that should be part of this. (Otherwise they complain to you that you shut down their work that they hadn't saved for 500+ hours...).

            • 3. Re: Force reboot after certain uptime?
              jwood8 Apprentice

              We're on 2016 - the problem we have is a lot of laptop users, external sales people, etc - if it were desktops then yeah I'd just shut them down over the weekend. I just wondered if there was some functionality in the tools to do this already because I like the standard reboot prompt interface, but I couldn't see a way to do it other than on a timed schedule which will annoy our users who do reboot. Hmmm. Maybe I can do a query for uptime and run a scheduled reboot task on any which are above a certain value.

              • 4. Re: Force reboot after certain uptime?
                phoffmann SupportEmployee

                I'd recommend having a check of that up-time be based on the client - not the inventory value.


                Remember that inventory records are just a snapshot in time - easier to launch a PowerShell or BAT or "as you prefer" script (or heck - custom vulnerability, but a local scheduler based script doesn't require comms to the Core) and base decisions on that.



                - If runtime == less than 72 hours - do nothing & quit gracefully.

                - If runtime == more than 72 hours -- throw reboot prompt.


                ... and such things. If you know this is mainly a headache for laptops & co - then begin with only targetting those & see what else is left-over. May be the case that you've only got some 5% of your estate "in-house" with such stuff to be worried about, while 80% of your laptop users aren't fans of rebooting for example.


                Comes down to what you want / need / view as reasonable .

                • 5. Re: Force reboot after certain uptime?
                  klevitan Specialist

                  This would be set in the reboot options.  Under Agent Settings you can define how you want reboots to be handled.  We set it so the user can defer reboots for up to 7 days.

                  • 6. Re: Force reboot after certain uptime?

                    Here's a powershell code block that will use your default agent settings to initiate the reboot if the system has been up for 7 days. It a lot shorter and simpler than anything you'll find online. You can save this to a ps1 file and create a local scheduled task to run it whenever you feel is a good time. Keep in mind it is going to use whatever the reboot settings are for the agent. If you want to use a different agent setting, I can give you the command for that but it will require that the system have access to your core to download the other setting.




                    ####START BLOCK###

                    $lastreboot = [datetime](Get-CimInstance -ClassName win32_operatingsystem | ForEach-Object {$_.lastbootuptime})

                    $today = [datetime](Get-Date)


                    If ($today -ge $lastreboot.AddDays(7))


                        Write-host "Reboot"

                        Start-Process -FilePath "C:\Program Files (x86)\LANDesk\LDClient\ldreboot.exe"


                    ###END BLOCK###