SERVER-003 · Script
Check Windows Service Health
Checks that key server services, such as DNS, DHCP and directory services, are running on each server.
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
| Name | What it does | Options | Default |
|---|---|---|---|
| Mode | Report (default) or Fix. | Report, Fix | Report |
| ComputerName | Server names to check. | (none) | |
| SearchBase | OU (distinguished name) whose enabled servers should be checked. Used when -ComputerName is empty. | ||
| ServiceNames | Service names to check. Default: directory, DNS, DHCP, Kerberos, replication, time and file sharing services. | NTDS, DNS, DHCPServer, Netlogon, Kdc, DFSR, W32Time, LanmanServer, LanmanWorkstation | |
| AllAutomatic | Also check every service set to Automatic (delayed and trigger-start services that stop by design are skipped). | False | |
| ExcludeNames | Service names to ignore. | (none) | |
| Server | Optional 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
- Run it first with the mode set to Report on one test OU, test account or test server. Nothing is changed in that mode.
- Read the log and confirm the planned changes are what you expect.
- Run your chosen settings on the same test target and confirm the result.
- Check the exit code: 0 = OK, 1 = needs attention, 2 = error (see log), 9 = this copy is past its Valid until date.
- 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
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | November 2026 | First release. |