eventviewer
query
windows-event-log
xml
栏目
Windows
原文
原文链接
我正在尝试在
Windows事件日志中搜索事件数据包含字符串TCP提供程序的任何内容,错误:0作为较长错误消息的一部分.为此,我创建了以下代码:
<QueryList> <Query Id="0" Path="Application"> <Select Path="Application">*[System[Provider[@Name='MyDemo' or @Name='AnotherDemo'] and (Level=2 or Level=3)]][EventData[Data[contains(.,'TCP Provider, error: 0')]]]</Select> </Query> </QueryList> 然而,这被视为无效的查询 – 我猜测无法识别contains语句(因为它看起来像这里使用的XPath语法的特殊版本.有谁知道我正在尝试的是可能的/如何这样做呢? 提前致谢, JB
你总是可以使用powershell脚本并通过powershell的where函数传递XML(支持-contains -like -match):
nv.ps1 $Query = @" <QueryList> <Query Id="0" Path="System"> <Select Path="System"> *[System[(EventID=20001)]] </Select> </Query> </QueryList> "@ $events = Get-WinEvent -FilterXml $Query ForEach ($Event in $Events) { # Convert the event to XML $eventXML = [xml]$Event.ToXml() Add-Member -InputObject $Event -MemberType NoteProperty -Force -Name DriverVersion -Value $eventXML.Event.UserData.InstallDeviceID.DriverVersion Add-Member -InputObject $Event -MemberType NoteProperty -Force -Name DriverDescription -Value $eventXML.Event.UserData.InstallDeviceID.DriverDescription Add-Member -InputObject $Event -MemberType NoteProperty -Force -Name Data -Value $eventXML.Event.EventData.Data } $Events | Select TimeCreated, Id, DriverDescription, DriverVersion, ProviderName, @{Name="MessageData";Expression={$_.Message + $_.Data}} | Where {$_.DriverDescription -match "NVIDIA GeForce GTX*"} | Out-GridView pause 用于启动它的cmd(nv.cmd): powershell.exe -executionpolicy bypass "& '.\nv.ps1'" 相关文章 |
|
来自: 问道东轩 > 《windows脚本及组策略》