What It Does
A system-state or Active Directory backup stamps the dSASignature attribute on the head of every directory partition the domain controller holds, and repadmin /showbackup reads it. The script reads the replication metadata of that attribute for each partition (domain, configuration, schema and any application partition such as DomainDnsZones) and takes the time it was last changed as the time of the last backup.
It writes one row per partition with the last backup time in UTC, the age in days and a status. It ends ALERT when any partition was last backed up more than MaxAgeDays days ago, has no backup recorded, or cannot be read, and the answer names the first problems. Otherwise it ends OK and names the oldest partition.
Two caveats. A domain controller that was never backed up may still show the time it was created for this attribute, so the age is then that of the installation. Backups taken by a product that does not use the Active Directory backup interface, such as a plain file copy of the database, do not move this time.
It only reads, and it changes nothing. On a computer that is not a domain controller it ends SKIPPED.
Before You Run It
- Run it on each domain controller, with administrator rights and the ActiveDirectory module (RSAT-AD-PowerShell).
- Set MaxAgeDays to match your backup schedule with some slack. The default is 7.
- Check that your backup product writes through the Active Directory backup interface, or this time will not move.
- An alert from a freshly built domain controller may only mean no backup has run yet.
Type and Risk
- Type: Monitor. It checks one condition. It exits 1 when it finds the problem, so your RMM can alert on it, 0 when all is well, and 2 when it could not run.
- Risk: Low. It reads and changes nothing.
- Restart: It never restarts the machine.
- Typical run: Under 15 seconds.
- Example answer: "Last AD backup 1.3 days ago (limit 7) on DC=contoso,DC=com; 5 naming context(s) checked"
- Tested before listing on a Windows Server 2025 domain controller (VM) 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.
- MaxAgeDays: The oldest acceptable last backup, in days. Whole number 1 to 365. Default 7.
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.