PowerShell Genie

Summarize failed logons

Script 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

The FilterHashtable pins the Security channel and event ID 4625 with a start time one day back, so the log service performs the selection rather than the pipeline.

The script

1PS> Get-WinEvent -FilterHashtable @{LogName= "Security";Id= 4625;StartTime=(Get-Date).AddDays(- 1)} | Select-Object TimeCreated,MachineName,Message

Script reader

Inspect before you run

Inspection only

Inspect the script below. It does not run in this browser.

Inspection only — no command has run.

    Show reference output
    1 TimeCreated MachineName Message
    2 ----------- ----------- -------
    3 9/10/2026 10:51:12 PM SRV01 Representative event message
    Inspect this example’s structure

    Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

    Get-WinEvent -FilterHashtable @{LogName= "Security";Id= 4625;StartTime=(Get-Date).AddDays(- 1)} | Select-Object TimeCreated,MachineName,Message
    1. Stage 1Get-WinEvent-FilterHashtable
    2. Stage 2Select-ObjectPositional values or no named parameters

      How it works

      The FilterHashtable pins the Security channel and event ID 4625 with a start time one day back, so the log service performs the selection rather than the pipeline. Each surviving record contributes its timestamp, the machine that logged it, and the message body carrying the account name and source details.

      Adapting it

      Group the results on a substring pulled from Message, or switch to Get-WinEvent -FilterXPath when the query needs to filter on the target account name, which a filter hashtable cannot express.

      Requirements

      Administrator rights or Event Log Readers membership on each target.

      If the result is unexpected

      A failed-logon summary has missing users or inflated counts.

      Event fields vary by event type and querying the wrong log or time window changes the dataset.

      1. Inspect one raw event and map its named fields before aggregating by account.

      Validate the result

      The summary total reconciles with the filtered events and includes the observation window.

      Keep the check reliable

      Keep event IDs and field mappings explicit instead of relying on a fixed property index.

      Primary documentation

      Get-WinEvent reference

      Continue
      Genie guideSummarize failed logons

      The FilterHashtable pins the Security channel and event ID 4625 with a start time one day back, so the log service performs the selection rather than the pipeline.