Skip to content
Menu

Something Is Logging Errors - Event ID and Text Match Monitor

Reads one event log for a time window and alerts when events matching your IDs, sources, message text and severity pass a count. Lists the newest matches.

Something is logging errors - event ID and text match monitor 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 Something is logging errors - event ID and text match monitor. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11, Windows Server 2016+; runs as SYSTEM
NeedsPowerShell 5.1; administrator rights
Read-onlyReads, changes nothing

What It Does

The script reads one event log for the last LookbackMinutes and counts the events that match every filter you set: EventIds, Providers (the event sources, with wildcards), MessageMatch (plain text, ignoring case), and Level. It alerts when more than MaxEvents match, and lists the 25 newest.

Set at least one filter. A filter left empty is not applied. At most 5000 events are read in a run, using any ID, provider or severity filters first. MessageMatch is applied after that limit, so narrow the filters or shorten the window on a busy log.

A source name that is not registered on the PC gives a warning, because it may be misspelled, and the run still ends OK when nothing matched. An unknown or disabled log gives an error instead of a quiet result.

Before You Run It

  • Decide what you are watching for before you schedule it. One clear event ID beats a broad text match.
  • Match the lookback to the schedule. A 60 minute window on an hourly check sees each event once.
  • Run it with administrator rights. The Security log and several others cannot be read without them.

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 20 seconds.
  • Example answer: "3 matching events in System in the last 60 min; latest 7034 Service Control Manager"
  • Tested before listing on Windows 11 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.

  • LogName: The event log to read, e.g. System, Application, Security or "Microsoft-Windows-TaskScheduler/Operational". Default System.
  • EventIds: Event IDs to match, separated by commas, e.g. "41, 6008". At most 20. Default any.
  • Providers: Event sources to match, separated by commas, e.g. "disk, Ntfs". Wildcards * and ? work. Default any.
  • MessageMatch: Text the event message must contain. Default any.
  • Level: Severity: Critical, Error (Critical and Error), Warning (Critical, Error and Warning) or Any. Default Error.
  • LookbackMinutes: How far back to read. Whole number, 1 to 43200. Default 60.
  • MaxEvents: Alert when more than this many events match. Whole number, 0 to 100000. Default 0 (any match alerts).

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-event-log-match.ps1 · 873 lines · 43.6 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.