Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intune-Graceful-Restart

Automates graceful device reboots via a single Microsoft Intune Win32 app. Uses registry-based state tracking and a startup scheduled task so reboots are coordinated through the standard Intune detection/remediation cycle, with no forced shutdowns.

Full documentation, workflow details, and deployment guidance is available in my blog post

Files

File Purpose
Install-Restart-Device.ps1 Win32 app install script. Sets up registry state and scheduled task; exits 1641 to trigger a graceful reboot.
Uninstall.ps1 Win32 app uninstall script. Removes registry values and scheduled task.
Trigger Reboot Notification.ps1 Helper script. Sets the restart flag and clears IME detection state to trigger the reboot cycle on demand. Use in Intune remediations.
App\makeapp.cmd Builds the .intunewin package from App\App\dummy.ps1.

Quick Start

1. Build the .intunewin package

Run App\makeapp.cmd to produce the .intunewin from App\App\dummy.ps1. This dummy file is just the required container; the actual scripts are uploaded separately.

2. Create the Win32 app in Intune (Step 1: placeholder commands)

Intune requires placeholder install/uninstall commands on initial creation before script installers can be selected. Upload the .intunewin, set installer type to Command line, and use install.exe / uninstall.exe as placeholders.

Set Device restart behavior to Determine behavior based on return codes so exit code 1641 triggers a hard reboot.

On the Detection rules tab configure:

Setting Value
Rule type Registry
Key path HKEY_LOCAL_MACHINE\Software\_Custom
Value name RestartRequired
Detection method String comparison
Operator Equals
Value False

Save the app.

3. Edit the saved app (Step 2: script installers)

Open the saved app, go to Properties > Program, and switch both installer types to PowerShell script. Upload Install-Restart-Device.ps1 as the install script and Uninstall.ps1 as the uninstall script. No install command arguments are needed; the script auto-derives the App ID from its staging folder.

4. Configure assignments and restart grace period

Assign the app to the target group. Enable the Restart grace period in the assignment settings to give users time to save their work before the device restarts.

5. Trigger a reboot

Run Trigger Reboot Notification.ps1 on a target device via an Intune remediation. It sets RestartRequired to True, clears the Win32 app's IME detection state, and restarts the IME service. On the next evaluation cycle, IME re-installs the app, which exits 1641 and Intune restarts the device.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages