Library / Windows Server and AD

SERVER-003 · Script

Check Windows Service Health

Checks that key server services, such as DNS, DHCP and directory services, are running on each server.

Version 1.0.0Language PowerShellUpdated November 2026

What it does

Connects to each server and checks the services in -ServiceNames. Services that are not installed on a server are skipped, so one list works for domain controllers, DNS, DHCP and file servers. With -AllAutomatic it also checks every other service set to start automatically. Report mode (default) changes nothing. Fix mode tries to start each stopped service once, waits, and checks it again. Services that are set to Disabled are never started.

Requirements

Windows PowerShell 5.1. Admin rights on the target servers. The ActiveDirectory module (RSAT) only when using -SearchBase.

How to run it

  • Run as: a service account with the directory rights the script lists, or SYSTEM on a domain controller or the server being checked
  • Run from: a domain-joined management server or admin workstation with the RSAT tools, as a scheduled task or from your management tool
  • Script type: PowerShell 5.1, 64-bit
  • User interaction: none; the script never prompts
  • Timeout: 30 minutes for large directories or many servers

Settings

NameWhat it doesOptionsDefault
ModeReport (default) or Fix.Report, FixReport
ComputerNameServer names to check.(none)
SearchBaseOU (distinguished name) whose enabled servers should be checked. Used when -ComputerName is empty.
ServiceNamesService names to check. Default: directory, DNS, DHCP, Kerberos, replication, time and file sharing services.NTDS, DNS, DHCPServer, Netlogon, Kdc, DFSR, W32Time, LanmanServer, LanmanWorkstation
AllAutomaticAlso check every service set to Automatic (delayed and trigger-start services that stop by design are skipped).False
ExcludeNamesService names to ignore.(none)
ServerOptional domain controller used for the -SearchBase lookup.

Exit codes

  • 0 = All checked services running (or restarted)
  • 1 = Stopped services remain, or a server is unreachable
  • 2 = Script error (see log)

Testing steps

  1. Run it first with the mode set to Report on one test OU, test account or test server. Nothing is changed in that mode.
  2. Read the log and confirm the planned changes are what you expect.
  3. Run your chosen settings on the same test target and confirm the result.
  4. Check the exit code: 0 = OK, 1 = needs attention, 2 = error (see log), 9 = this copy is past its Valid until date.
  5. Roll out to a small group next, then everyone.

Rollback steps

Report mode changes nothing. Fix mode only starts services that were set to start automatically and had stopped. To undo, stop the service again in Services or with Stop-Service.

Version and change log

VersionDateChanges
1.0.0November 2026First release.