我已经做了大量研究,但是还没有找到成功的解决方案,我正在尝试从.txt文件中提取计算机名称,并从每个系统中获取错误日志。如果我在-ComputerName
之后写出每个系统名称,则可以正常运行,但是从.txt中提取则出现错误。
Get-Content "C:\Users\donovan.claxton\Desktop\PS\pc names.txt" | ForEach-Object {
Get-EventLog -ComputerName $_ -Newest 50 -LogName System -EntryType Error |
Export-Csv -Path "C:\Users\donovan.claxton\Documents\Error logs\System Errors$((Get-Date).ToString('MM-dd-yyyy_hh-mm-ss')).csv"
}
Get-EventLog : The network path was not found. At C:\Users\donovan.claxton\Documents\Powershell Scripts\eventlog system script.ps1:2 char:1 + Get-EventLog -ComputerName $_ -Newest 50 -LogName System -EntryType E ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-EventLog], IOException + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.GetEventLogCommand