When deploying software via SCCM I thought wouldn’t it be nice if there was greater flexibility regarding system reboot prompts for the end user. Sure you can enable a maintenance window and push your software out during that time, but we have at times been caught where a software push is needed during business hours.

So I came up with this PowerShell script which you can run as part of a task sequence when deploying emergency/unscheduled software installs. The script generates a GUI which provides the end-user with three options;

  1. Restart the computer
  2. Schedule a restart (note in here I have hard-coded this for 6pm)
  3. Cancel the restart

The script also starts a count-down timer to automatically restart the computer after 3 minutes if no user interaction occurs.

 

customrestart

Example Script Use – SCCM TS

In the below example we are going to create a Package in SCCM which contains the script file, you will also need to include two exe files from MDT which allow you to run the script in interactive mode.

Locate ServiceUI.exe and TSProgressUI.exe (obviously picking the x86 or x64 where applicable) and add these into your package source. You should have something that looks like this ;

rebootfiles

Now add a Run Command Line entry into your TS and use the following command line;

ServiceUI.exe -process:TSProgressUI.exe %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File CustomRestart.ps1

rebootts

When the Task Sequence is run, you should now have the restart prompt appear;

rebootcapture

Script Source

 

Download Link
The script is available to download from:
https://gallery.technet.microsoft.com/scriptcenter/Custom-PowerShell-GUI-7c7fbda8

(654)

comments
  • Bruce Lyons
    Posted at 7:58 pm 3rd October 2016
    Bruce Lyons
    Reply
    Author

    So, what’s the minimum version of Powershell necessary for this to run? And yes, there’s an actual reason I need to ask this question.

    • modalyit
      Posted at 8:11 pm 3rd October 2016
      modalyit
      Reply
      Author

      Hi Bruce,

      I have tested the code back as far as PowerShell 2.0 with no issues. I hope that helps.

      Maurice

  • John
    Posted at 9:33 pm 22nd November 2016
    John
    Reply
    Author

    What’s the benefit of doing this instead of just doing a normal application deployment with “ConfigMgr requires a mandatory reboot” set and Allow Installations and Reboots during Maintenance windows checked?

    • Maurice Daly
      Posted at 9:49 pm 22nd November 2016
      Maurice Daly
      Reply
      Author

      Hi John,

      The benefit of doing this is if you have to urgently push software to your users but you want them to have some control over when a mandatory reboot occurs. In my own environment I have had several instances where I have been advised to push out an application update that requires a reboot, for some users the software was critical and others not so much so providing them with an option to reschedule keeps the user population content. This feature is actually due to be built into future updates of the product.

      Maurice

  • Leave a Reply