无法查询Windows日志'转发事件'日期
问题描述:
我们正在尝试创建一个PowerShell函数来查询Windows事件日志以查看两个日期之间发生的事件。无法查询Windows日志'转发事件'日期
$FilterXML = @"
<QueryList>
<Query Id="0" Path='$LogName'>
<Select Path='$LogName'>
*[System[TimeCreated[@SystemTime>='2017-04-17T09:48:24.000Z' and
@SystemTime<='2017-04-19T09:50:24.999Z']]]
</Select>
</Query>
</QueryList>
"@
Get-WinEvent -FilterXml $FilterXML
我们已经建立了我们的Windows Server 2012中收集来自其它服务器的事件,像在Windows Server 2008 R2:查询自定义日志或标准日志时 下面的代码工作正常。在事件查看器中检查事件时,我们可以看到它们在日志Forwarded Events
中可用。在GUI或PowerShell中查询它们时没有日期时,这很好。
但是,当我们想在GUI或PowerShell中查询相同的'Forwarded Events'日志时,通过添加一个日期来自和一个日期来选择,它只是说没有找到匹配。这是不正确的,因为当我们检查这些事件时,它们都具有在这些日期之间的日期的TimeCreated
属性。
Get-WinEvent : No events were found that match the specified selection criteria.
当运行在事件被创建的源计算机上的相同的查询它工作正常使用的日期。在收集器服务器上,仅选择最近7天或24小时内的事件时,这也可以正常工作。所以这与事件的转发以及我猜想的对象有关。我们检查了两台服务器上的区域设置,它们与日期格式的荷兰语(比利时)相同。
例事件其中的日期不能使用:
Message : johofman - Script ended
Id : 199
Version :
Qualifiers : 0
Level : 4
Task : 1
Opcode :
Keywords : 36028797018963968
RecordId : 768
ProviderName : My script name
ProviderId :
LogName : My log name
ProcessId :
ThreadId :
MachineName : SERVER.domain.net
UserId :
TimeCreated : 19/04/2017 16:02:56
ActivityId :
RelatedActivityId :
ContainerLog : c:\windows\system32\winevt\logs\forwardedevents.evtx
MatchedQueryIds : {}
Bookmark : System.Diagnostics.Eventing.Reader.EventBookmark
LevelDisplayName : Information
OpcodeDisplayName : Info
TaskDisplayName :
KeywordsDisplayNames : {Classic}
Properties : {System.Diagnostics.Eventing.Reader.EventProperty}
是否有一个原因,这是工作的所有事件日志而不是Forwarded Events
?
事件记录已按照here所述进行了配置。
谢谢你的帮助。
答
如何使用-filterHashTable
尝试?例如:
$filter = @{
Path = "$env:SystemRoot\System32\Winevt\Logs\ForwardedEvents.evtx"
StartTime = get-date '2017-04-17T09:48:24.000Z'
EndTime = get-date '2017-04-19T09:50:24.999Z'
}
然后
$events = Get-WinEvent -FilterHashtable $filter
GET-WinEvent -LogName ForwardedEvents? –
给我正确的结果,在'-FilterXML'中使用时也是如此,但是在添加日期时不能使用。 – DarkLite1