As a part of my security admin duties, I need to look through windows event logs on the domain controller for failed login attempts.
What I currently do is go to the security logs within windows event viewer and filter by Audit Failures. I have to do this on a daily basis. It is a bit of a cumbersome and tedious process for a simple task.
I would like to be able to use Powershell to pull out the information I need and export it to CSV so I can easily skim through the information and sort as needed.
As an example of what I was attempting, I tied the following:
Get-WinEvent -FilterHashtable @{ logname = 'Security'; id = 4771 } |
Export-Csv -NoType "c:\Output.csv"
The problem is, this output does now show the username, target IP, or port. When I look at one of the events, I see that these values can be found in the raw XML view (TargetUserName
, IpAddress
, IpPort
) but I just cant figure out how to query those values to show up in the output. Does anyone know how this can be accomplished?
|%{$_.TOXML()}
orExport-Clixml
– Thomas Weller