Skip to main content

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:

  1. 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.
  2. 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.
  3. 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 FieldDescription
cPVAL Pending RebootManual override to force a prompt cycle.
cPVAL Last PromptedTimestamp of the last successful prompt. Managed automatically.
cPVAL Times PromptedCounter for how many times the user has been prompted. Managed automatically.
cPVAL Reboot Prompt When Pending RebootEnable/Disable detection based on Windows Registry keys.
cPVAL Reboot Prompt Uptime DaysUptime threshold (days) to trigger a reboot. Set to 0 to disable.
cPVAL Reboot Prompt CountMax number of prompts allowed before the cycle resets (or force reboot occurs).
cPVAL Reboot Prompt Duration Between PromptMinimum hours to wait between consecutive prompts.
cPVAL Reboot Prompt Skip WeekendsEnable to suppress prompts on Saturdays and Sundays.
cPVAL Reboot Prompt Suppress Time Window24-hour time range (HHmm-HHmm) to suppress prompts (e.g., '1800-0800').
cPVAL Reboot if Not Logged InEnable to reboot immediately if no user is signed in.

Automation Setup/Import

Automation Configuration

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, and cPVAL Times Prompted when resetting state (self-healing).