当我在 $ComputerName 中有 1 台计算机时,它可以工作,但是当我添加另一个计算机名称时,它会给出错误。[代码和错误][1] 抱歉,以下是代码:
$ComputerName = 'Server1','Server2' ForEach($Computer in $ComputerName){ $Info = Get-WinEvent -ComputerName $Computer -FilterHashTable @{Logname='System';ID=1074,6008,1076} | Sort-Object MachineName, TimeCreated, ID
| 组对象 MachineName、TimeCreated、ID、消息| Select-Object @{N="Computer";E={$_.Group[0].MachineName}},
@{N="TimeCreated"; E={$ .Group[0].TimeCreated}}, @{N="Error ID";E={$_.Group[0].ID}},
@{N="Message"; E={$ .Group[0].Message.Replace(" r",' ').Replace("
n",'')}} ` | 导出-Csv -NoTypeInformation -Path C:\ServerLogs\events3.csv;}
错误:
Get-WinEvent : RPC 服务器在 C:\EventLogs\TEST.ps1:3 char:9 处不可用
- $Info = Get-WinEvent -ComputerName $Computer -FilterHashTable @{Logn ...
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (:) [Get-WinEvent], EventLogException
- fullyQualifiedErrorId:System.Diagnostics.Eventing.Reader.EventLogException,Microsoft.PowerShell.Commands.GetWinEventCommand