Library / Windows Server and AD

SERVER-031 · Script

Review Server Event Logs

Collects recent critical, error and warning events from servers and summarizes them by source and event ID.

Version 1.0.0Language PowerShellUpdated November 2026Report only, changes nothing

What it does

Reads the logs you choose (System and Application by default) from each target server for the last -Hours hours, at the levels you choose (Critical and Error by default). Writes two CSV files:

  • Summary: one row per server, log, source and event ID, with a count, first and last time seen,

and a sample message, sorted with the noisiest first

  • Details: every event read (up to -MaxEvents per server and log)

Use it for a morning check or a weekly review instead of opening Event Viewer on each server. Targets are the servers you name, the servers in an OU, or this computer. Read-only.

Requirements

Windows PowerShell 5.1. Membership in Event Log Readers (or admin) on the targets, with remote event log access allowed. The ActiveDirectory module (RSAT) only when -SearchBase is used.

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
ComputerNameServers to check. If empty, uses -SearchBase, or this computer.(none)
SearchBaseOU (distinguished name) whose enabled servers are checked.
LogNameLogs to read. Default: System, Application. Others include Security and Directory Service.System, Application
LevelLevels to include: Critical, Error, Warning. Default: Critical, Error.Critical, Error
HoursHow far back to read. Default: 24.24
MaxEventsMost events to read per server and log. Default: 2000.2000
AlertOnCritical (default) exits 1 when any Critical event is found. Any exits 1 for any event found. Never always exits 0.Critical, Any, NeverCritical
ServerOptional domain controller used to read the OU.

Exit codes

  • 0 = Nothing that matches AlertOn
  • 1 = Events found that match AlertOn, or some servers could not be read
  • 2 = Script error (see log)

Testing steps

  1. Run it on one test OU, test account or test server and check the output and log.
  2. Check the exit code: 0 = OK, 1 = needs attention, 2 = error (see log), 9 = this copy is past its Valid until date.
  3. 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

VersionDateChanges
1.0.0November 2026First release.