我想找到多个服务器的某个事件 ID 列表的最近一次出现。我没有看到一个很好的方法来做到这一点。如果我使用-newest
开关,我必须根据每个服务器事件日志的相对大小以及我感兴趣的事件在该数量的条目中发生的机会来处理数字。在下面的示例中,服务器F6WINMSSTEST3
在前 10,000 个条目中没有我要查找的内容。有人知道这样做的好方法吗?
我想要的是为每个服务器列出我正在寻找的事件的每个 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.