Reboot Pending Prompt - Detection
Overview
This script serves as the detection logic for the Reboot Pending Prompt solution. Its primary function is to intelligently decide whether a reboot prompt should be displayed to the user.
It performs checks in three key areas:
- Operational Safety: Before evaluating necessity, the script checks if the Reboot Pending prompt - Autofix is currently active (specifically checking for the scheduled task it manages). If a prompt cycle is already in progress, this script exits immediately to prevent conflicting or duplicate actions.
- Necessity: It determines if a reboot is actually required by checking Windows Registry keys (for pending updates), comparing system uptime against a configured threshold, or checking for a manual administrator override.
- Timing & Convenience: If a reboot is needed, the script then validates if the current moment is appropriate for a prompt. It checks constraints such as "Quiet Hours" (suppress windows), weekend exclusions, user presence (logged in vs. lock screen), and ensures the user isn't prompted too frequently.
If the script determines a reboot is needed, the timing is valid, and no conflicting prompts are active, it returns an exit code that triggers the remediation script.
Sample Run
Note: This script is specifically engineered to operate as the detection condition within the Reboot Pending Prompt - Windows Workstation policy. Manual execution is not recommended, as the script's output is intended to trigger automated remediation actions rather than provide direct feedback.
Dependencies
Custom Fields
| Custom Field | Description |
|---|---|
| cPVAL Pending Reboot | Manual override to force a prompt cycle. |
| cPVAL Last Prompted | Timestamp of the last successful prompt. Managed automatically. |
| cPVAL Times Prompted | Counter for how many times the user has been prompted. Managed automatically. |
| cPVAL Reboot Prompt When Pending Reboot | Enable/Disable detection based on Windows Registry keys. |
| cPVAL Reboot Prompt Uptime Days | Uptime threshold (days) to trigger a reboot. Set to 0 to disable. |
| cPVAL Reboot Prompt Count | Max number of prompts allowed before the cycle resets (or force reboot occurs). |
| cPVAL Reboot Prompt Duration Between Prompt | Minimum hours to wait between consecutive prompts. |
| cPVAL Reboot Prompt Skip Weekends | Enable to suppress prompts on Saturdays and Sundays. |
| cPVAL Reboot Prompt Suppress Time Window | 24-hour time range (HHmm-HHmm) to suppress prompts (e.g., '1800-0800'). |
| cPVAL Reboot if Not Logged In | Enable to reboot immediately if no user is signed in. |
Automation Setup/Import
Output
- Activity Details: Text output indicating if a reboot is required and if conditions were met.
- Custom Field: Updates
cPVAL Pending Reboot,cPVAL Last Prompted, andcPVAL Times Promptedwhen resetting state (self-healing).