我不知道xpath。我看过 W3 教程,但它们似乎不起作用。
我正在使用 wevtutil 从 Windows 事件日志中提取事件
我在 Windows Server 2008 R2 Enterprise 上
如果我使用以下命令仅列出最后三个事件:
wevtutil qe Application /c:3 /rd:true /e:root
我得到以下结果:
<?xml version="1.0"?>
<root>
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider EventSourceName="Software Protection Platform Service" Guid="{E23B33B0-C8C9-472C-A5F9-F2BDFEA0F156}" Name="Microsoft-Windows-Security-SPP"/>
<EventID Qualifiers="16384">902</EventID>
<Version>0</Version>
<Level>0</Level>
<Task>0</Task>
<Opcode>0</Opcode>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2016-04-22T08:20:30.000000000Z"/>
<EventRecordID>49232</EventRecordID>
<Correlation/>
<Execution ThreadID="0" ProcessID="0"/>
<Channel>Application</Channel>
<Computer>EU9742K8WEB01.emea.sitel-world.net</Computer>
<Security/>
</System>
<EventData>
<Data>6.1.7601.17514</Data>
</EventData>
</Event>
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider EventSourceName="Software Protection Platform Service" Guid="{E23B33B0-C8C9-472C-A5F9-F2BDFEA0F156}" Name="Microsoft-Windows-Security-SPP"/>
<EventID Qualifiers="16384">1003</EventID>
<Version>0</Version>
<Level>4</Level>
<Task>0</Task>
<Opcode>0</Opcode>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2016-04-22T08:20:30.000000000Z"/>
<EventRecordID>49231</EventRecordID>
<Correlation/>
<Execution ThreadID="0" ProcessID="0"/>
<Channel>Application</Channel>
<Computer>EU9742K8WEB01.emea.sitel-world.net</Computer>
<Security/>
</System>
<EventData>
<Data>55c92734-d682-4d71-983e-d6ec3f16059f</Data>
<Data>1: 0cb1d6b4-3c07-487f-82fc-886d44a646aa, 1, 0 [(0 [0xC004F014, 0, 0], [(?)(?)(?)(?)(?)(?)])(1 )(2 )]2: 2d727362-1f80-4a74-9e4d-e7c79826e659, 1, 0 [(0 [0xC004F014, 0, 0], [(?)(?)(?)(?)(?)(?)])(1 )(2 )]3: 4bcc8879-e699-4159-a810-f829566662ca, 1, 0 [(0 [0xC004F014, 0, 0], [(?)(?)(?)(?)(?)(?)])(1 )(2 )]4: 620e2b3d-09e7-42fd-802a-17a13652fe7a, 1, 1 [(0 [0x00000000, 1, 0], [(?)(?)( 1 0x00000000 30 0 msft:rm/algorithm/volume/1.0 0x00000000 254400)(?)(?)(?)])(1 )(2 )]5: 6a4bd364-4b60-4856-a727-efb59d94348e, 1, 0 [(0 [0xC004F014, 0, 0], [(?)(?)(?)(?)(?)(?)])(1 )(2 )]6: 8fe15d04-fc66-40e6-bf34-942481e06fd8, 1, 0 [(0 [0xC004F014, 0, 0], [(?)(?)(?)(?)(?)(?)])(1 )(2 )]7: b297426d-464d-4af1-abb2-3474aeecb878, 1, 0 [(0 [0xC004F014, 0, 0], [(?)(?)(?)(?)(?)(?)])(1 )(2 )]8: c60b048b-8071-4532-8398-f15f4c981861, 1, 0 [(0 [0xC004F014, 0, 0], [(?)(?)(?)(?)(?)(?)])(1 )(2 )]9: c74dc7f6-ea35-4bd7-9776-333ab5dddae6, 1, 0 [(0 [0xC004F014, 0, 0], [(?)(?)(?)(?)(?)(?)])(1 )(2 )]10: c99b641f-c4ea-4e63-bec3-5ed2ccd0f357, 1, 0 [(0 [0xC004F014, 0, 0], [(?)(?)(?)(?)(?)(?)])(1 )(2 )]11: ea36520d-fbfe-4042-acd8-fe926781b615, 1, 0 [(0 [0xC004F014, 0, 0], [(?)(?)(?)(?)(?)(?)])(1 )(2 )]</Data>
</EventData>
</Event>
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider EventSourceName="Software Protection Platform Service" Guid="{E23B33B0-C8C9-472C-A5F9-F2BDFEA0F156}" Name="Microsoft-Windows-Security-SPP"/>
<EventID Qualifiers="16384">1066</EventID>
<Version>0</Version>
<Level>4</Level>
<Task>0</Task>
<Opcode>0</Opcode>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2016-04-22T08:20:30.000000000Z"/>
<EventRecordID>49230</EventRecordID>
<Correlation/>
<Execution ThreadID="0" ProcessID="0"/>
<Channel>Application</Channel>
<Computer>EU9742K8WEB01.emea.sitel-world.net</Computer>
<Security/>
</System>
<EventData>
<Data>C:\Windows\system32\sppwinob.dll, msft:spp/windowsfunctionality/agent/7.0, 0x00000000, 0x00000000C:\Windows\system32\sppobjs.dll, msft:rm/algorithm/phone/1.0, 0x00000000, 0x00000000C:\Windows\system32\sppobjs.dll, msft:rm/algorithm/pkey/2005, 0x00000000, 0x00000000C:\Windows\system32\sppobjs.dll, msft:spp/TaskScheduler/1.0, 0x00000000, 0x00000000C:\Windows\system32\sppobjs.dll, msft:spp/volume/services/kms/1.0, 0x00000000, 0x00000000C:\Windows\system32\sppobjs.dll, msft:spp/volume/services/kms/licenserenewal/1.0, 0x00000000, 0x00000000</Data>
</EventData>
</Event>
</root>
如您所见,有一个带有 SystemTime 属性的 TimeCreated 元素。我只想说 SystemTime 介于两次之间的那些。
如果我在上一个命令中添加 xpath:
wevtutil qe Application /c:3 /rd:true /e:root /q:"TimeCreated"
所有返回的是:
<root>
</root>
如果我将 xpath 更改为Event/System/TimeCreated
,我会得到与上面列出的相同的 xml。
所以两个问题:
如何在没有所有其他元素的情况下仅获得 TimeCreated 元素(这对我来说不太重要)?
如何检索 SystemTime 属性在两个指定值之间的位置?
如果有人可以向我解释为什么我不能按照 W3 教程中的建议单独使用 TimeCreated,那也很好。