I am currently exporting the last 7 days of Security microsoft windows security auditing logs via powershell to csv.
It works, but with way to much detail, and also, not properly formatted. For instance, from the csv, the 'message' cell has this in
"An account was successfully logged on.
Subject: Security ID: X Account Name: - Account Domain: - Logon ID: 0x0
Logon Type: 3
Impersonation Level: Impersonation
New Logon: Security ID: X Account Name: XXX Account Domain: XXX Logon ID: XXX Logon GUID: {XXX}
Process Information: Process ID: 0x0 Process Name: -
Network Information: Workstation Name: - Source Network Address: XXX.XXX Source Port: XXX ............
Now to get the above into csv i am using this powershell script
[xml]$CustomView = @"
<QueryList>
<Query Id="0" Path="Security">
<Select Path="Security">*[System[(EventID=4624 or EventID=4672 or EventID=4648 or EventID=463) and TimeCreated[timediff(@SystemTime) <= 604800000]]] </Select>
</Query>
</QueryList>
"@
Get-WinEvent -FilterXML $CustomView | Export-CSV "C:\CustomView_$(Get-Date -format "yyyy-MM-DD").csv"
How is it possible to export a csv with the following columns?
Event Id, Security ID, Account Name, Account Domain, Logon ID, Logon, TimeCreated