我想查找多個服務器的某個事件ID列表的最近一次出現次數。我沒有看到一個很好的方法來做到這一點。如果我使用-newest
交換機,我必須根據每臺服務器的事件日誌的相對大小以及我有興趣在該條目數量內發生的事件的機率來使用該數字。在我下面的示例中,服務器F6WINMSSTEST3
沒有我在前10000條中找到的內容。任何人都知道這樣做的好方法?Powershell Get-eventlog查詢。如何返回符合標準的條目數量爲
我想列出每個服務器每個服務器的每個ID的最新條目的單個實例,以便我可以看到它們何時發生。在一個完美的世界裏,每個服務器都會列出最近的3個ID。
$Servers = "F6WINMSSTEST","F6WINMSSTEST2","F6WINMSSTEST3","F6WINMSSTEST4","F6WINMSSTEST5"
Foreach ($server in $Servers) {
$server
get-eventlog -computer $server -logname system -newest 10000 | where-object { $_.eventid - eq 6005 -or $_.eventid -eq 6009 -or $_.eventid -eq 6006} }
輸出示例:
F6WINMSSTEST
Index Time EntryType Source InstanceID Message
----- ---- --------- ------ ---------- -------
108265 Feb 08 08:33 Information EventLog 2147489653 The Event log service was started.
108264 Feb 08 08:33 Information EventLog 2147489657 Microsoft (R) Windows (R) 6.01. 7601 Service Pack 1 Multiprocessor Free.
108247 Feb 08 08:31 Information EventLog 2147489654 The Event log service was stopped.
104703 Nov 16 08:41 Information EventLog 2147489653 The Event log service was started.
104702 Nov 16 08:41 Information EventLog 2147489657 Microsoft (R) Windows (R) 6.01. 7601 Service Pack 1 Multiprocessor Free.
104688 Nov 16 08:39 Information EventLog 2147489654 The Event log service was stopped.
F6WINMSSTEST2
39265 Jul 06 08:01 Information EventLog 2147489653 The Event log service was started.
39264 Jul 06 08:01 Information EventLog 2147489657 Microsoft (R) Windows (R) 6.00. 6002 Service Pack 2 Multiprocessor Free.
39249 Jul 06 08:00 Information EventLog 2147489654 The Event log service was stopped.
39060 Jul 06 02:03 Information EventLog 2147489653 The Event log service was started.
39059 Jul 06 02:03 Information EventLog 2147489657 Microsoft (R) Windows (R) 6.00. 6002 Service Pack 2 Multiprocessor Free.
39044 Jul 06 02:02 Information EventLog 2147489654 The Event log service was stopped.
F6WINMSSTEST3
F6WINMSSTEST4
6591 Jul 06 08:01 Information EventLog 2147489653 The Event log service was started.
6590 Jul 06 08:01 Information EventLog 2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Uniprocessor Free.
6589 Jul 06 08:00 Information EventLog 2147489654 The Event log service was stopped.
6531 Jul 05 11:52 Information EventLog 2147489653 The Event log service was started.
6530 Jul 05 11:52 Information EventLog 2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Uniprocessor Free.
6529 Jul 05 11:51 Information EventLog 2147489654 The Event log service was stopped.
F6WINMSSTEST5
55124 Nov 06 19:11 Information EventLog 2147489653 The Event log service was started.
55123 Nov 06 19:11 Information EventLog 2147489657 Microsoft (R) Windows (R) 5.02. 3790 Service Pack 2 Uniprocessor Free.
55122 Nov 06 19:10 Information EventLog 2147489654 The Event log service was stopped.