Skip to content
Menu

Is Active Directory Healthy - Services, Replication, FSMO, Dcdiag

Checks directory services, SYSVOL and NETLOGON, the five FSMO role holders, replication partners and dcdiag, and alerts on any failure.

Is Active Directory healthy - services, replication, FSMO, dcdiag 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 Is Active Directory healthy - services, replication, FSMO, dcdiag. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows Server 2016+ (domain controller); runs as SYSTEM
NeedsPowerShell 5.1, administrator rights, ActiveDirectory module (RSAT-AD-PowerShell), dcdiag.exe
Read-onlyReads, changes nothing

What It Does

The script is read-only. Run it on a domain controller; on any other computer it ends SKIPPED, and if the ActiveDirectory module is missing it ends ERROR. Each check is one row.

Services: NTDS, Netlogon, KDC and W32Time must be running. DNS and DFSR must be running when they are installed; a domain controller that does not host DNS, or still uses the old FRS for SYSVOL, is not an alert. Shares: SYSVOL and NETLOGON must be shared. FSMO roles: the five role holders, the schema master, domain naming master, PDC emulator, RID master and infrastructure master, must answer on the directory port, TCP 389.

Replication: every replication partner of this domain controller must show a last result of success, no consecutive failures, and a last success newer than MaxReplicationAgeHours, 24 by default. It reads the same data as repadmin /replsummary, through typed values instead of text, so it works in every Windows language. A single domain controller has no partners, which is healthy and not an alert.

dcdiag: it runs dcdiag /q, which prints only what failed, and alerts when it prints anything or exits non-zero. The SystemLog, DFSREvent, KccEvent and FrsEvent tests are skipped so unrelated event log warnings do not make the run fail. A dcdiag that does not finish within DcdiagTimeoutSeconds, 300 by default, counts as a failure. Set RunDcdiag=false if dcdiag takes too long for your RMM's script timeout. The answer lists the first three problems and how many more there are.

Before You Run It

  • Run it on each domain controller, not on a member server.
  • Set MaxReplicationAgeHours to match how often your sites replicate. The default is 24 hours.
  • Set RunDcdiag=false if dcdiag runs past your RMM's timeout.
  • Install the AD PowerShell module with Install-WindowsFeature RSAT-AD-PowerShell if it is missing.
  • Schedule it in your RMM and alert on exit 1.

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 2 minutes.
  • Example answer: "AD healthy on DC01: 6 services, 2 shares, 5 FSMO roles, replication OK (2 partners), dcdiag clean"
  • 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.

  • MaxReplicationAgeHours: Alert when a replication partner's last successful replication is older than this many hours. Whole number, 1 to 720. Default 24.
  • RunDcdiag: Run the dcdiag check. true or false. Default true. Set false when dcdiag takes too long for your RMM's script timeout.
  • DcdiagTimeoutSeconds: Stop dcdiag after this many seconds and count that as a failure. Whole number, 30 to 1800. Default 300.

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

test-ad-health.ps1 · 942 lines · 47.8 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.