Created
May 8, 2018 23:38
-
-
Save timbutler/2bb352f12943cb0cffa36f3ef982ff17 to your computer and use it in GitHub Desktop.
PowerShell - Windows Login Audit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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