我們正在嘗試創建一個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所述進行了配置。
謝謝你的幫助。
GET-WinEvent -LogName ForwardedEvents? –
給我正確的結果,在'-FilterXML'中使用時也是如此,但是在添加日期時不能使用。 – DarkLite1