Auto Reboot Management
Overview
This automation is the engine of the Auto Reboot Management - NinjaOne solution. It reads the Auto Reboot Management custom fields of every Windows device through the NinjaOne API, works out the schedule that applies to each device, and writes a restart request to cPVAL Auto Reboot Scheduled For on every device due to restart before its next run. The device then restarts itself through the reboot trigger compound conditions. The automation also schedules maintenance mode around the restart, checks whether earlier restarts happened, and keeps cPVAL Auto Reboot Status and cPVAL Auto Reboot Failure current.
The Auto Reboot Management scheduled task runs this automation every hour, at 5 minutes past the hour, on one device. Don't schedule it anywhere else: every run covers the whole tenant, so running it on more devices writes every request several times and uses up the API rate limit. The automation changes nothing on the device it runs on.
The automation works in the time zone of the device it runs on. It reads the selected restart days and times in that time zone, and every time it writes to cPVAL Auto Reboot Status and cPVAL Auto Reboot Failure is in that time zone too, which the TimeZone column and the end of each failure show. For devices in other time zones, see Time Zones.
Requirements
- One Windows device that's always online, such as a server
- Run As:
System - PowerShell 5.1
- HTTPS access from that device to the NinjaOne instance
- An API application with the Client Credentials grant type and the Monitoring and Management scopes, stored in cPVAL Ninja API Client ID and cPVAL Ninja API Client Secret. The application used by WYSIWYG Custom Field Report - Organization and Global KB works.
How It Works
- Authenticate: reads the Client ID and Client Secret from the secure custom fields and signs in to the NinjaOne API.
- Read: reads every Windows device, the Auto Reboot Management custom fields at every level, and which servers run the domain controller or Hyper-V services.
- Check earlier restarts: compares each device's last boot time with the restart it last requested, and records the result.
- Request restarts: writes the restart time to cPVAL Auto Reboot Scheduled For on every online device due to restart before the next run, within the hour, and schedules maintenance mode around it. A device that's offline is recorded as
Skipped - Offlineand restarts at its next scheduled time. - Record: updates cPVAL Auto Reboot Status where a value changed, records new failures in cPVAL Auto Reboot Failure, and clears the fields of devices no longer enabled.
Sample Run
Default settings
Run every hour by the Auto Reboot Management scheduled task on one device of a US2 instance.
| Script Variable | Value |
|---|---|
| Instance URL | us2.ninjarmm.com |
| Schedule Interval Minutes | 60 |

Another NinjaOne instance
Run every hour on one device of an EU instance, using the default interval of 60 minutes.
| Script Variable | Value |
|---|---|
| Instance URL | eu.ninjarmm.com |

Parameters
| Name | Calculated Name | Example | Accepted Values | Required | Default | Type | Description |
|---|---|---|---|---|---|---|---|
| Instance URL | instanceUrl | us2.ninjarmm.com | Any valid NinjaOne instance host | False | us2.ninjarmm.com | string/text | NinjaOne instance the API application belongs to. Must match the tenant's region. |
| Schedule Interval Minutes | scheduleIntervalMinutes | 60 | 60 to 240 | False | 60 | Integer | How often the automation runs, in minutes. Restarts due within this many minutes of the start of the run are requested, so it must match the Recur every value of the Auto Reboot Management scheduled task: 60 for every hour. |
Custom Fields
| Custom Field | Scope | Type | Description |
|---|---|---|---|
| cPVAL Ninja API Client ID | System | Secure | Client ID of the API application. Read at runtime. |
| cPVAL Ninja API Client Secret | System | Secure | Client Secret of the API application. Read at runtime. |
| cPVAL Auto Reboot | Organization, Location, Device | Drop-down | Which Windows devices are restarted. |
| cPVAL Auto Reboot Include DC | Organization, Location, Device | Drop-down | Includes domain controllers. |
| cPVAL Auto Reboot Include Hyper-V Host | Organization, Location, Device | Drop-down | Includes Hyper-V hosts. |
| cPVAL Auto Reboot Days | Organization, Location, Device | Multi-select | Days of the week to restart on. |
| cPVAL Auto Reboot Time | Organization, Location, Device | Drop-down | Time of the restart. |
| cPVAL Auto Reboot Week Server | Organization, Location, Device | Drop-down | Week of the month servers restart in. |
| cPVAL Auto Reboot Week Workstation | Organization, Location, Device | Drop-down | Week of the month workstations restart in. |
| cPVAL Auto Reboot Maint Minutes Server | Organization, Location, Device | Integer | Maintenance mode minutes around a server restart. |
| cPVAL Auto Reboot Maint Minutes Workstation | Organization, Location, Device | Integer | Maintenance mode minutes around a workstation restart. |
| cPVAL Auto Reboot Pending Check Server | Organization, Location, Device | Drop-down | Restarts servers only when a reboot is pending. |
| cPVAL Auto Reboot Pending Check Workstation | Organization, Location, Device | Drop-down | Restarts workstations only when a reboot is pending. |
| cPVAL Auto Reboot Failure Ticket | Organization, Location, Device | Drop-down | Not read by this automation. Used by the reboot failure compound conditions. |
| cPVAL Auto Reboot Status | Device | WYSIWYG | Written with the effective schedule, next restart and result of the last restart. |
| cPVAL Auto Reboot Failure | Device | Text | Written when a scheduled restart fails. |
| cPVAL Auto Reboot Scheduled For | Device | Text | Written with the restart time in UTC when a restart is due. |
Every Auto Reboot Management custom field needs its API permission set to Read Only or Read/Write, and cPVAL Auto Reboot Status, cPVAL Auto Reboot Failure and cPVAL Auto Reboot Scheduled For need Read/Write. The run fails before anything is changed if a field is missing or has the wrong type.
Dependencies
- Custom Field: cPVAL Ninja API Client ID
- Custom Field: cPVAL Ninja API Client Secret
- Custom Field: cPVAL Auto Reboot
- Custom Field: cPVAL Auto Reboot Days
- Custom Field: cPVAL Auto Reboot Time
- Custom Field: cPVAL Auto Reboot Status
- Custom Field: cPVAL Auto Reboot Failure
- Custom Field: cPVAL Auto Reboot Scheduled For
- Compound Condition: Auto Reboot Management - Reboot Trigger [Windows Servers]
- Compound Condition: Auto Reboot Management - Reboot Trigger [Windows Workstations]
- Automation: Auto Reboot Management - Reboot Machine
- Scheduled Task: Auto Reboot Management
- Audit Report: Auto Reboot Management Status
- Solution: Auto Reboot Management - NinjaOne
Automation Setup/Import
Output
- Activity Details, ending with a run summary and a single line beginning with
SuccessorFailure - Custom Field: cPVAL Auto Reboot Scheduled For
- Custom Field: cPVAL Auto Reboot Status
- Custom Field: cPVAL Auto Reboot Failure
- Maintenance mode on the devices due to restart
Changelog
2026-11-11
- Initial version of the document