Skip to content

Instantly share code, notes, and snippets.

@robert-moses
Last active August 29, 2019 14:50
Show Gist options
  • Save robert-moses/96809e6b235af44921086016d5d183e3 to your computer and use it in GitHub Desktop.
Save robert-moses/96809e6b235af44921086016d5d183e3 to your computer and use it in GitHub Desktop.
WIndows Event Log alerting
# Well Known SIDs of interest
# SID: S-1-5-32-544
# Name: Administrators
#
# SID: S-1-5-21domain-512
# Name: Domain Admins
#
# Test lockout - EventID: 4740
(1..6)| %{ runas /user:DQGSOCAS4681\test1 cmd}
#
# Get Event Logs
# get-eventlog -log security | where-object {$_.EventID -match "^680$|^528$|^672$|^4768$|^4776$" –AND $_.UserName -notmatch 'SYSTEM|NETWORKSERVICE|LOCAL SERVICE|ANONYMOUS LOGON' –AND $_.TimeGenerated -gt [datetime]::today } | sort-object -property TimeGenerated | select-object -last 100 | Format-Table -AutoSize –Wrap
get-eventlog -log security | where-object {$_.EventID -match "^4740$" –AND $_.UserName -notmatch 'SYSTEM|NETWORKSERVICE|LOCAL SERVICE|ANONYMOUS LOGON' –AND $_.TimeGenerated -gt [datetime]::today } | sort-object -property TimeGenerated | select-object -last 100 | Format-Table -AutoSize –Wrap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment