Skip to content

Instantly share code, notes, and snippets.

@timbutler
Created May 8, 2018 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timbutler/2bb352f12943cb0cffa36f3ef982ff17 to your computer and use it in GitHub Desktop.
Save timbutler/2bb352f12943cb0cffa36f3ef982ff17 to your computer and use it in GitHub Desktop.
PowerShell - Windows Login Audit
Write-Host "Getting Login Events"
$Out = @()
$List = Get-EventLog Security -Computer localhost | Where-Object {$_.InstanceId -eq 4624}
ForEach($Entry in $List) {
If($Entry.ReplacementStrings[18] -notcontains "-"){
$Out += New-Object PSObject -Property @{
InstanceID = $Entry.InstanceId
User = $Entry.ReplacementStrings[5]
SourceIP = $Entry.ReplacementStrings[18]
Time = $Entry.TimeGenerated
Type = $Entry.EntryType
}
}
}
# Write the results to a Grid
$Out | Select * | Sort Time -Descending | Out-GridView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment