无法查询Windows日志'转发事件'日期

问题描述:

我们正在尝试创建一个PowerShell函数来查询Windows事件日志以查看两个日期之间发生的事件。无法查询Windows日志'转发事件'日期

$FilterXML = @" 
<QueryList> 
    <Query Id="0" Path='$LogName'> 
     <Select Path='$LogName'> 
      *[System[TimeCreated[@SystemTime&gt;='2017-04-17T09:48:24.000Z' and 
      @SystemTime&lt;='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所述进行了配置。

谢谢你的帮助。

+0

GET-WinEvent -LogName ForwardedEvents? –

+0

给我正确的结果,在'-FilterXML'中使用时也是如此,但是在添加日期时不能使用。 – DarkLite1

如何使用-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 
+0

同样的信息我很害怕,'找不到符合指定选择标准的事件。真奇怪。因为查询没有日期给我的事件,我可以看到他们的正确日期... – DarkLite1

+0

你是否尝试玩日期,即前一天,直到第二天? –

+0

是的,我做了第一件事。在将路径更改为ForwardedEvents时,它在远程源服务器上运行良好,但在收集器服务器上运行良好。 24小时前尝试时也可以使用,只能在日期之间使用。 – DarkLite1