0

我需要监视特定工作站集的特定事件 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 : 未找到网络路径。在 line:6 char:15 + ... $events = Get-EventLog -ComputerName $Workstation -LogName "Applica ... + ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-EventLog], IOException + FullyQualifiedErrorId:System.IO.IOException,Microsoft.PowerShell.Commands.GetEventLogCommand

4

1 回答 1

0

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

通过执行上述脚本,这不会产生任何错误,但会比平时花费更长的时间。现在,任何过滤此选项并在短时间内提供输出的建议。非常感谢您的建议。

于 2017-03-09T05:09:03.097 回答