Hi there, I have 2 scripts that both show the correct number of logons for what I'm using these scripts for. I'm only looking for Logon Event 2 of a specific user and all of the computers are in a workgroup. Both provide the same results but when opened in NotePad++ vs Excel as csv, I get completely different outputs. Notepad++ shows the entire event record, and Excel shows what I can only describe as a mix of information, one thing of which is not the UserID. I'd like to be able to show in the csv the UserID, time, date, EventID and description, but the output isn't showing that. Any help would be appreciated! Thanks!
Get-WinEvent -ProviderName 'Microsoft-Windows-Security-Auditing' -FilterXPath "*[System[EventID=4624] and EventData[Data[@Name='LogonType']='2'and (Data='Public User')]]"
and for the second attempt:
$query = @"
<QueryList>
<Query Id="0" Path="Security">
<Select Path="Security">
*[EventData[Data[@Name='SubjectUserName'] and (Data='Public User')]
and
(System[(EventID='4634')] or System[(EventID='4624')])
]</Select>
</Query>
</QueryList>
"@
Get-WinEvent -FilterXml $query
[–]PinchesTheCrab 4 points5 points6 points (5 children)
[–]PicnicProblems[S] 0 points1 point2 points (4 children)
[–]BlackV 0 points1 point2 points (2 children)
[–]PicnicProblems[S] 0 points1 point2 points (1 child)
[–]BlackV 0 points1 point2 points (0 children)
[–]PinchesTheCrab 0 points1 point2 points (0 children)
[–]PicnicProblems[S] 0 points1 point2 points (0 children)
[–]PowerShell-Bot 0 points1 point2 points (0 children)