我试图通过创建自定义视图来做事件查看器可以做的事情,然后将其保存为evtx文件。以下是我到目前为止所拥有的以及通过在事件查看器中创建自定义视图而生成的自定义XML。也可以使用powershell。
$queryXML =
Path="Application"
Path="Application">*[System[Provider[@Name='Application'] and (Level=1 or Level=2 or Level=3)]]
Path="Security">*[System[Provider[@Name='Application'] and (Level=1 or Level=2 or Level=3)]]
Path="Setup">*[System[Provider[@Name='Application'] and (Level=1 or Level=2 or Level=3)]]
Path="System">*[System[Provider[@Name='Application'] and (Level=1 or Level=2 or Level=3)]]
Path="ForwardedEvents">*[System[Provider[@Name='Application'] and (Level=1 or Level=2 or Level=3)]]
wevtutil epl C:\Users\user\Desktop\test.evtx "/q: $queryXML"-
<QueryList>
<Query Id="0" Path="Application">
<Select Path="Application">*[System[(Level=1 or Level=2)]]</Select>
<Select Path="Security">*[System[(Level=1 or Level=2)]]</Select>
<Select Path="Setup">*[System[(Level=1 or Level=2)]]</Select>
<Select Path="System">*[System[(Level=1 or Level=2)]]</Select>
<Select Path="ForwardedEvents">*[System[(Level=1 or Level=2)]]</Select>
</Query>
</QueryList>发布于 2018-10-01 21:28:07
想出了一个方法。将查询xml保存为.txt文件,而不是指定像"system“这样的事件日志名称,使用.txt文件的路径和查询。
发布于 2022-04-22 14:24:21
为了在接受的解决方案上进一步扩展,您可以将XML结构化查询保存为一个文件(例如"SQ.xml"),然后修改wevtutil语句,如下所示:
wevtutil epl SQ.xml temp.evtx /sq:true这告诉wevtutil使用保存在SQ.xml中的XML查询,并将日志导出到名为temp.evtx的文件中。您必须指定/sq:true来告诉它查询结构化查询文件。
结构化查询格式主要是XPath格式,但对其进行了一些细微的调整。更多信息可以是在这里发现的。例如:
<QueryList>
<Query Id="0">
<Select Path="System">*[System[TimeCreated[@SystemTime >= '2022-04-22T05:00:00' and @SystemTime <= '2022-04-22T15:00:00']]]</Select>
<Select Path="Application">*[System[TimeCreated[@SystemTime >= '2022-04-22T05:00:00' and @SystemTime <= '2022-04-22T15:00:00']]]</Select>
</Query>
</QueryList>上述查询获取系统和应用程序日志文件的今天(4月22日上午5时至下午3时协调世界时。注意,因为这是XML,所以必须对大于和小于符号进行编码。
https://stackoverflow.com/questions/52596289
复制相似问题