Hi!
I’m working on a script that I’m going to run as a daily scheduled task. The script creates a htm-file with information from several servers. Among other things, I want to list error logs for the last 7 days from servers listed in $servers.
My case is this. When I run the following command, it’s all good, and it gives me the logs I’m asking for:
Get-EventLog -ComputerName $servers -LogName System -After (Get-Date).AddDays(-7) -Before (Get-Date) -Newest 5| Select-Object MachineName, TimeWritten, EntryType, Source, Message
If I add “-EntryType Error”, PowerShell hangs, and after a while it times out:
Get-EventLog -ComputerName $servers -LogName System -EntryType Error -After (Get-Date).AddDays(-7) -Before (Get-Date) -Newest 5| Select-Object MachineName, TimeWritten, EntryType, Source, Message
Why is this happening? Is there a better way to get error logs from several servers?