【问题标题】:Powershell Get-Winevent FilterhashtablePowershell Get-Winevent Filterhashtable
【发布时间】:2014-08-19 18:25:31
【问题描述】:

这是我现在的一个有效查询。

powershell "Get-WinEvent -EA SilentlyContinue -FilterHashtable @{ProviderName='Microsoft-Windows-DriverFrameworks-UserMode';ID=2003,2100;StartTime='2014-08-18 16:01:57';EndTime='2014-08-18 23:59:59'} | where {$_.Message -match '27, 23'}| ConvertTo-Csv -NoTypeInformation | %{ $_ -replace """`r`n""",',' }  | select -Skip 1| Out-File -Append c:\TEMP\TIMELINE\TEMP.csv"

我怎样才能改变它以使其获取:

(Event ID 2003)
      OR
(Event ID 2100 and Message -match '27, 23')

谢谢你..

【问题讨论】:

    标签: powershell


    【解决方案1】:

    只需将 Where 语句更改为使用 -OR 语句,然后使用 -AND 语句对 ID 和消息进行分组:

    where {$_.ID -eq "2003" -or ($_.ID -eq "2100" -and $_.Message -match '27, 23')}
    

    【讨论】:

      【解决方案2】:

      Filterhashtable 不支持 bool 表达式。 您可以采取 2 种解决方法。

      1. 使用 PowerShell where 管道。
      2. 使用 -FilterXml 参数代替 Filterhashtable

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-03-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多