在交互模式下,这有效:
Get-Eventlog -log application -after ((get-date).addMinutes(-360)) -EntryType Error
现在我想过滤掉某些消息,以下没有过滤所需的词:
Get-Eventlog -log application -after ((get-date).addMinutes(-360)) -EntryType Error | where-object {$_.$Message -notlike "*Monitis*"}
另外,如何在 where-object 上设置多个条件?
在我的脚本中,我在 -and 语句上遇到错误:
$getEventLog = Get-Eventlog -log application -after ((get-date).addMinutes($minutes*-1)) -EntryType Error
# list of events to exclude
$getEventLogFiltered = $getEventLog | where-object {$_.Message -notlike "Monitis*"
-and $_.Message -notlike "*MQQueueDepthMonitor.exe*"
}
$tableFragment = $getEventLogFiltered | ConvertTo-Html -fragment
错误:
-and : The term '-and' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At D:\scripts\EventLogExtract2.ps1:24 char:40
+ -and $_.Message -notlike "*MQQueueDepthMo ...
+ ~~~~