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
| 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. |
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.
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.
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.
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.
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.