This is Event ID 4688. How do you directly extract the 0x3pa99 stored in the Data node with the Name attribute equal to "SubjectLogonId". I was trying to use it with Get-WinEvent -FilterXml $xpath but I don’t know save the 0x3pa99 part as a variable to be used later on
$xpath = @"
<QueryList>
<Query Id="0">
<Select Path="Security">*[System[(EventID=4688)]] and
*[EventData[Data[@Name='SubjectLogonID'] and Data='0x3pa99']]
</Select>
</Query>
</QueryList>
"@
Get-WinEvent -FilterXml $xpath
The EventLogEntry Object class in PowerShell has a very cool property named ReplacementStrings
Where you would index it. However, it’s hard for me to provide you with the correct code because I don’t have an example object in my event log. You would basically use whatever code you have that is capturing that exact event ID into a variable. Let’s say $MyEvent is your variable. Once you have it in the ISE or whatever where it stays in memory you would play around with the index number as follows.
$MyEVent.ReplacementStrings[0] and see if it contains the value "0x3pa99" then
$MyEVent.ReplacementStrings[1]
$MyEVent.ReplacementStrings[2] ## and so on until you find the "Index" of that string you are looking for.
Once you have it you would use normal string processing to remove the junk you didn’t want. for example. . .
But as the mighty admins have said we can’t really help you unless you share the code you have so far and what you have at least tried to do for yourself.
Are you saying you want to have a variable that contains this value, or another similar value, to use in filtering? If that’s an accurate guess, try this:
More description of what you’re trying to accomplish would be really helpful. The big picture will give us context to understand what your goal is. Otherwise, we’re just guessing.
So, 4688 is the event ID for process creation. Depending on your audit policy, you will get a ton of these. I suspect what you really want is a way to query for that Event ID, then extract the ‘SubjectLogonId’ results from that query? Is that an accurate statement?
If so … try this … XPath altered a bit to remove the system created process fluff …