SERVER-019 · Script
Check Server Availability
Checks that each server answers on the network and on the ports you depend on.
Version 1.0.0Language PowerShellUpdated November 2026Report only, changes nothing
What it does
For each server, records:
- DNS: whether the name resolves, and to which address
- Ping: whether it answers a ping (many firewalls block this, so it is reported but not required)
- Ports: whether each TCP port in -Port accepts a connection (default 3389 Remote Desktop,
445 file sharing, 5985 PowerShell remoting) A server counts as down when its name does not resolve or none of its ports answer. A server counts as degraded when some ports answer and others do not. Targets are the servers you name, the servers in an OU, or this computer. Read-only.
Requirements
Windows PowerShell 5.1. The ActiveDirectory module (RSAT) only when -SearchBase is used. No admin rights needed on the targets.
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 |
|---|---|---|---|
| ComputerName | Servers to check. If empty, uses -SearchBase, or this computer. | (none) | |
| SearchBase | OU (distinguished name) whose enabled servers are checked. | ||
| Port | TCP ports to test. Default: 3389, 445, 5985. | 3389, 445, 5985 | |
| TimeoutMs | How long to wait for each port, in milliseconds. Default: 2000. | 2000 | |
| AlertOn | Down (default) exits 1 when any server is down. Degraded also counts partial failures. Never always exits 0. | Down, Degraded, Never | Down |
| Server | Optional domain controller used to read the OU. |
Exit codes
- 0 = All servers up (per AlertOn)
- 1 = One or more servers down or degraded (per AlertOn)
- 2 = Script error (see log)
Testing steps
- Run it on one test OU, test account or test server and check the output and log.
- 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 only. Nothing is changed, so nothing needs to be rolled back.
Version and change log
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | November 2026 | First release. |