Is there a way to filter for events where a certain attribute is NOT the given string in Windows (Server 2016) Event Viewer's limited dialect of XPath?
I'm trying to get a view on logon events, but only actual user logons (console and RDP).
This is accepted as a filter, but gives too many results, as if the final AND term is ignored:
<QueryList> <Query Id="0" Path="Security"> <Select Path="Security">
*[System[(EventID=4624)]]
and *[EventData[Data[@Name='LogonType'] and (Data=1 or Data=8 or Data=9)]]
and *[EventData[Data[@Name='TargetUserName'] and (Data!='SYSTEM')]]
</Select> </Query> </QueryList>
When I change the third test to this, it is flagged as "invalid query".
and not *[EventData[Data[@Name='TargetUserName'] and (Data='SYSTEM')]]
Yet I found an answer to another XPath question that suggests to prefer this form, because != gives the wrong result when one side of the comparison is a set instead of a value.
And the same for this, invalid query
and *[EventData[Data[@Name='TargetUserName'] and not (Data='SYSTEM')]]
or this
and *[EventData[Data[@Name='TargetUserName'] and !(Data='SYSTEM')]]