Event ID reference and Get-WinEvent query builder
Tick the events you are after and get a PowerShell query that runs as is: FilterHashtable when that is enough, FilterXml when you filter on a field such as TargetUserName. Every event lists what it means, which audit policy has to be on, and where it is logged. Everything runs in your browser.
Start from:
# Events:
# 4740 A user account was locked out
$filter = @{
LogName = 'Security'
Id = 4740
StartTime = (Get-Date).AddDays(-1)
}
$events = Get-WinEvent -FilterHashtable $filter -ErrorAction SilentlyContinue
$events | ForEach-Object {
# EventData fields by name, so the columns do not depend on field order
$data = @{}
foreach ($d in ([xml]$_.ToXml()).Event.EventData.Data) { if ($d.Name) { $data[$d.Name] = $d.'#text' } }
[pscustomobject]@{
TimeCreated = $_.TimeCreated
Computer = $_.MachineName
Id = $_.Id
TargetUserName = $data['TargetUserName']
TargetDomainName = $data['TargetDomainName']
SubjectUserName = $data['SubjectUserName']
}
} | Sort-Object TimeCreated -Descending | Format-Table -AutoSize -Wrap Run it in an elevated PowerShell session: reading the Security log needs admin rights or Event Log Readers membership.
Codes you will see in these events
LogonType (4624, 4625, 4634)
| 2 | Interactive: at the keyboard |
| 3 | Network: file share, most remote management |
| 4 | Batch: scheduled task |
| 5 | Service: a service started under this account |
| 7 | Unlock |
| 8 | NetworkCleartext: password sent in clear (often IIS basic auth) |
| 9 | NewCredentials: runas /netonly |
| 10 | RemoteInteractive: RDP |
| 11 | CachedInteractive: cached credentials, no DC reachable |
Status and SubStatus (4625, 4776)
| 0xC000006A | Wrong password |
| 0xC0000064 | User name does not exist |
| 0xC000006D | Generic logon failure: check SubStatus |
| 0xC0000234 | Account is locked out |
| 0xC0000072 | Account is disabled |
| 0xC0000193 | Account has expired |
| 0xC0000071 | Password has expired |
| 0xC0000224 | User must change password at next logon |
| 0xC000006F | Outside allowed logon hours |
| 0xC0000070 | Not allowed to log on from this workstation |
| 0xC000015B | Logon type not granted on this machine |
| 0xC0000133 | Clock out of sync with the domain controller |
Kerberos failure codes (4768, 4771)
| 0x6 | Client not found in the directory (bad user name) |
| 0x12 | Account disabled, expired or locked out |
| 0x17 | Password has expired |
| 0x18 | Pre-authentication failed: wrong password |
| 0x25 | Clock skew too great |