← script library

Monitor Local Security Event Logs

Security & AuditingJanuary 12, 2025

This PowerShell script monitors local security event logs and extracts information about failed logon attempts. It can be useful for system administrators to track potential security breaches.

powershell
$currentDate = Get-Date

$startTime = $currentDate.AddHours(-24)

$failedLogons = Get-WinEvent -LogName Security -FilterHashtable @{ID=4625; StartTime=$startTime}

$failedLogonInfo = $failedLogons | Select-Object TimeCreated, @{Name='User';Expression={$_.Properties[5].Value}}, @{Name='Machine';Expression={$_.Properties[18].Value}}

$failedLogonInfo | Format-Table -AutoSize

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.