Skip to main content

Excessive Logon Attempts

Overview​

Counts the failed logon attempts (Security event ID 4625) recorded since the last run and raises an alert when the count reaches the threshold, which can indicate a brute-force or password-spraying attack. The count is a total for the device across all users, taken after the configured exclusions. Batch and service logons, and a computer account failing from its own workstation, are never counted.

Whenever any failed logons are counted, the activity details list them grouped by user, domain and source IP address, along with the workstation, logon type, failure status and logon process. The script saves the time each run started in cPVAL Excessive Logon LastRunTime, so the next run starts where this one ended. It does not change anything else on the device.

The automation is the evaluation script of the Monitor - Excessive Logon Attempts compound condition in the Excessive Logon Attempts solution.

note

The first run, and any run where cPVAL Excessive Logon LastRunTime is empty or invalid, checks the last 60 minutes.

Requirements​

  • Windows. The compound condition runs it only on domain controllers whose cPVAL Roles Detected field contains Infrastructure Master.
  • Run As: System
  • PowerShell 5.1
  • Logon failure auditing enabled, so Windows records event ID 4625. Windows Server enables it by default.

Sample Run​

Image1

Parameters​

Every parameter is optional. A parameter left empty uses the matching custom field, so leave them empty in the compound condition and set the values in the custom fields at the organization, location or device level. A value entered in a parameter replaces the custom field value for that run rather than adding to it.

List entries can be separated by commas or semicolons. Matching is not case-sensitive, and every entry accepts the wildcards * (any number of characters) and ? (exactly one character).

NameExampleAccepted ValuesRequiredDefaultTypeDescription
Threshold20A whole number greater than 0FalseEmpty, which uses cPVAL Excessive Logon Threshold, or 10 when that is empty tooStringNumber of failed logons since the last run that raises the alert. The alert is raised when the count is equal to or greater than this value. The count is a total across all users, after exclusions. 0, a negative number or text that is not a number uses 10.
ExcludeUsersscanner; svc_*; *$UsernamesFalseEmpty, which uses cPVAL Excessive Logon ExcludeUsersStringUsernames to ignore on every computer and in every domain. *$ ignores all computer (machine) accounts.
ExcludeByComputerFRONTDESK-01/reception; LAB-PC07/*COMPUTER/account entries. A backslash also works.FalseEmpty, which uses cPVAL Excessive Logon ExcludeByComputerStringAccounts to ignore when the computer in the entry is the Domain or the WorkstationName of the failed logon. * as the account matches every account.
ExcludeByDomainCONTOSO/svc_scan; FABRIKAM/*DOMAIN/account entries. A backslash also works.FalseEmpty, which uses cPVAL Excessive Logon ExcludeByDomainStringAccounts to ignore only when they belong to the domain in the entry. For a local account, the domain is the computer name. * as the account matches every account.
ExcludeByWorkstationCOPIER-2F/scan2folder; TRAINING-*/*WORKSTATION/account entries. A backslash also works.FalseEmpty, which uses cPVAL Excessive Logon ExcludeByWorkstationStringAccounts to ignore only when the attempt comes from the workstation in the entry. * as the account matches every account.
ExcludeLogonProcessCHAP; Advapi; SeclogoLogon process names, such as CHAP, Advapi, Seclogo or KerberosFalseEmpty, which uses cPVAL Excessive Logon ExcludeLogonProcessStringLogon process names to ignore everywhere. Avoid NtLmSsp and User32, which would hide most password-guessing attacks.

Custom Fields​

Custom FieldScopeTypeDescription
cPVAL Enable Excessive Logon DetectionOrganization, Location, DeviceDrop-downRead by the compound condition, not by the script. Disable stops the condition from running the automation on the device. Empty works like Enable.
cPVAL Excessive Logon ThresholdOrganization, Location, DeviceTextNumber of failed logons that raises the alert. Used when the Threshold parameter is empty. Empty uses 10.
cPVAL Excessive Logon ExcludeUsersOrganization, Location, DeviceMulti-lineUsernames to ignore everywhere. Used when the ExcludeUsers parameter is empty.
cPVAL Excessive Logon ExcludeByComputerOrganization, Location, DeviceMulti-lineCOMPUTER\account entries to ignore on or from one computer. Used when the ExcludeByComputer parameter is empty.
cPVAL Excessive Logon ExcludeByDomainOrganization, Location, DeviceMulti-lineDOMAIN\account entries to ignore in one domain. Used when the ExcludeByDomain parameter is empty.
cPVAL Excessive Logon ExcludeByWorkstationOrganization, Location, DeviceMulti-lineWORKSTATION\account entries to ignore from one workstation. Used when the ExcludeByWorkstation parameter is empty.
cPVAL Excessive Logon ExcludeLogonProcessOrganization, Location, DeviceTextLogon process names to ignore everywhere. Used when the ExcludeLogonProcess parameter is empty.
cPVAL Excessive Logon LastRunTimeDeviceTextTime the script last ran, read and written by the script on every run that reads the Security log. The next run counts failed logons from this time onward. Does not need to be filled in manually.

Dependencies​

Automation Setup/Import​

Automation Configuration

Output​

Changelog​

2026-11-11​

  • Updated the document to the current automation documentation standard.
  • Removed the Minutes parameter. The script now counts the failed logons recorded since its last run, saved in cPVAL Excessive Logon LastRunTime, and checks the last 60 minutes when no last run time is saved.
  • Made Threshold optional. When it is empty, the script uses cPVAL Excessive Logon Threshold, or 10 when that is empty too.
  • Added the ExcludeUsers, ExcludeByComputer, ExcludeByDomain, ExcludeByWorkstation and ExcludeLogonProcess parameters and their custom fields.

2025-08-14​

  • Fixed the bug in the script that triggered the alert only after 2 Failed Logon attempts

2025-07-07​

  • Initial version of the document