Get-Eventlog - 监视特定事件 ID

Get-Eventlog - To monitor specific event ID

我需要监控特定工作站组的特定事件 ID。 事件 ID 监视器:监视特定工作站集的特定事件 ID

$Workstations = gc c:\NotBackedUp\Workstation.txt
foreach ($Workstation in $Workstations)
{
    $events = Get-EventLog -ComputerName $Workstation -LogName "Application" | Where-Object     {$_.EventID -eq "2"} | Format-List
}
$events >> C:\NotBackedUp\Test.txt

但是我会得到如下错误,

Get-EventLog : The network path was not found. At line:6 char:15 + ... $events = Get-EventLog -ComputerName $Workstation -LogName "Applica ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-EventLog], IOException + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.GetEventLogCommand

$Workstations = gc c:\NotBackedUp\Workstation.txt foreach ($Workstations in $Workstations) { $events = Get-WinEvent -ComputerName $工作站 -LogName "Application" | Where-Object {$_.EventID -eq "2"} |格式列表 } $事件 >> C:\NotBackedUp\Test.txt

通过执行上面的脚本,这不会给出任何错误,但比平时需要更长的时间。 现在,任何过滤此选项并在短时间内给出输出的建议。非常感谢您的建议。