Skip to content
Menu

RMM Agent Stopped, Disabled or Missing - Start It Again

Starts stopped or disabled RMM agent services again, and installs the agent when it is missing and you supply an HTTPS installer with its SHA-256.

RMM agent stopped, disabled or missing - start it again is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review RMM agent stopped, disabled or missing - start it again. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11, Windows Server 2016+; runs as SYSTEM
NeedsPowerShell 5.1, administrator rights; internet access to InstallerUrl only when you set it
Changes thingsChanges what it runs on

What It Does

For each service name in AgentServices the script reads the service. A stopped service is started and waited on until it is Running. A stopped and disabled service is set to Automatic first. A running service is left alone, unless RestartRunning is true, in which case it is restarted once. Its direct service changes are limited to the names you give, with no wildcards. If an installer runs, it makes its own changes.

When a named service is missing, it installs the agent only when both InstallerUrl and InstallerSha256 are set. It downloads the file over HTTPS into the secured MSP Outpost data folder, checks the SHA-256, and only then runs it: an .msi through msiexec quietly with no restart, an .exe directly, with InstallerArguments. A wrong hash deletes the file and stops the run.

Most RMMs run scripts through the agent, and a stopped agent cannot run anything, so run this from a Windows scheduled task as SYSTEM, a second management tool, or your RMM's watchdog. The script also protects itself: if a named service started this run, it will not restart that service. Whether a running agent is actually talking to the RMM cannot be seen from the PC, so a hung agent is not detected on its own.

Before You Run It

  • Find the agent's service names, not display names, in services.msc on a working PC.
  • Run it with DryRun=true first and read what it would start or install.
  • Take the installer's SHA-256 from a file you trust, with Get-FileHash, before setting InstallerUrl.
  • Keep a secret site key out of InstallerArguments where your vendor offers another way: it shows on the process command line.

Type and Risk

  • Type: Action. It makes its change, checks the change worked and says what changed. It exits 0, or 2 when it could not do the job.
  • Risk: Low. Set DryRun=true, or run it with -WhatIf, to list every change without making any.
  • What it changes: Starts services; sets a disabled service to Automatic; optionally restarts running services; optionally installs the agent from a checked installer.
  • Restart: It never restarts the machine itself. When a restart is needed to finish, the answer says so.
  • Typical run: Under 1 minute (installer time extra).
  • Example answer: "Repaired 1 of 2 agent service(s): started CagService"
  • Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • AgentServices: The agent's Windows service NAMES (not display names), separated by comma, semicolon or new line, for example CagService for Datto RMM or NinjaRMMAgent for NinjaOne. Required. No wildcards.
  • RestartRunning: true to restart services that are running (for a hung agent). Default false.
  • InstallerUrl: HTTPS address of the agent installer (.exe or .msi) to run when a named service is missing. Needs InstallerSha256. Default empty (never installs).
  • InstallerSha256: The SHA-256 of the installer file, 64 hex characters. Required with InstallerUrl.
  • InstallerArguments: Arguments passed to the installer (for an .msi they follow /i "file" /qn /norestart). They are visible on the process command line, so keep a secret site key out of them where the vendor offers another way. Default empty.
  • TimeoutSeconds: How long to wait for a service to reach Running, and for a new service to appear after an install. Whole number, 5 to 600. Default 30.

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

repair-rmm-agent.ps1 · 955 lines · 50.2 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.