Windows
View all Worklets
WindowsWindows

Windows - Maintenance Tasks - Restart Automox Agent

Schedule automatic restarts of the Automox Agent at specified times to maintain consistent monitoring

Worklet Details

What the agent restart scheduler does

This Automox Worklet™ creates and registers a Windows scheduled task named "Restart AMAGENT" that automatically restarts the Automox Agent service on a daily schedule. The Worklet runs at a time you specify (in 24-hour military format, such as 08:00 for 8 am), and includes intelligent logic to only restart the service when it's safe to do so.

The scheduled task checks whether the Automox Agent is currently running a command. If the agent is not actively executing a remediation or task from the console, the task restarts the service. If the agent is busy, it waits and restarts only when the current operation completes. This prevents interrupting critical Worklet execution.

The task runs with System-level privileges (highest permissions) and includes a one-hour execution timeout. Windows creates the scheduled task if it doesn't already exist, preventing duplicate tasks across multiple Worklet runs.

Why schedule regular agent restarts

Long-running Automox Agent services accumulate memory leaks, experience resource contention, or develop hung processes that prevent communication with the console. The agent stops reporting compliance data, misses scheduled Worklet execution windows, and shows as offline in the console despite running on the endpoint. Manual troubleshooting requires IT staff to identify affected endpoints, remote into systems, and restart services one at a time across potentially hundreds of endpoints.

This Automox Worklet automates agent health maintenance by scheduling daily restarts at your specified time. The scheduled task clears accumulated resource issues and ensures the agent operates at peak efficiency. You reduce missed remediation windows and stale compliance data by proactively restarting the service before problems occur. Scheduling restarts during low-activity periods like early morning hours minimizes business disruption while maintaining comprehensive endpoint monitoring and compliance enforcement across your entire Windows infrastructure.

How the agent restart task works

  1. Evaluation phase: The Worklet checks whether a scheduled task named "Restart AMAGENT" already exists on the endpoint. If the task is present, evaluation passes and no remediation occurs. If the task is absent, the Worklet flags the endpoint for remediation.

  2. Remediation phase: The Worklet creates a new scheduled task with your specified restart time. If a task by that name already exists, the Worklet removes it first and creates a fresh task. The task is configured to run with System privileges, run on battery power, and enforce a one-hour maximum execution window. The task's action is a PowerShell command that checks if the Automox Agent is actively running a command; if it is idle, the command restarts the service immediately.

Agent restart requirements

  • Windows 7 or later (including Windows Server 2008 R2 and newer)

  • Automox Agent installed and running on the endpoint

  • Local Administrator or SYSTEM privileges required to create and modify scheduled tasks

  • Worklet parameter: restart time in 24-hour format (for example, 08:00 for 8 am, 14:30 for 2:30 pm, 23:59 for 11:59 pm)

  • Task Scheduler service enabled and running on the endpoint

Expected agent behavior after task creation

After completion, Windows Task Scheduler contains a scheduled task named "Restart AMAGENT" configured to run daily at your specified time. At the scheduled time, the task checks if the agent is idle and restarts the service if no Worklet execution is in progress. The restart completes within seconds with no user-visible prompts or notifications. The agent reconnects to the Automox console and resumes monitoring and remediation activities.

Verify the task by opening Task Scheduler (taskschd.msc) and locating "Restart AMAGENT" in the task library. Check the task properties to confirm the trigger time matches your configured schedule. Review the task history tab to see execution records and verify successful restarts. Monitor the Automox console to confirm the agent reconnects shortly after the scheduled restart time. Test the task manually by right-clicking it and selecting "Run" to verify it restarts the agent successfully without disrupting ongoing Worklet execution.

How to validate restart automox agent changes

  1. Run this Worklet on a pilot Windows endpoint and review evaluation output for restart automox agent.

  2. Confirm Automox activity logs show successful completion and exit code 0.

  3. Verify endpoint state using checks aligned to evaluation script logic, such as Get-ScheduledTask, Where-Object, Write-Output.

  4. Validate remediation effects from script operations such as New-ScheduledTaskPrincipal, New-ScheduledTaskSettingsSet, New-TimeSpan, then rerun evaluation for compliance.

View in app
evalutation image
remediation image

Consider Worklets your easy button

What's a Worklet?

A Worklet is an automation script, written in Bash or PowerShell, designed for seamless execution on endpoints – at scale – within the Automox platform. Worklet automation scripts perform configuration, remediation, and the installation or removal of applications and settings across Windows, macOS, and Linux.

do more with worklets