0

I'm trying to retrieve eventlog (with certain conditions) from multiple servers. It only checks the first server and does not move onto the next one. What is wrong with it? I tried different scripts (This are my first scripts ever, I know they suck)

Clear-Host
$serverArray = "DC1PRISEAS1","DC2DRISEAS1","ATLAH1PRBUSOB01","ATLAH1PRECLHS01","DC2STGHYPFS1","DC2STGHYPFS2","DC2STGHYPRS1","DC2STGHYPRS2","DC2STGHYPHFM1"

foreach ($element in $serverArray) 
{

    Write-Output "$element"
    Get-Eventlog -Logname System -After (Get-Date).Adddays(-1) -ComputerName $element | Where {$_.entryType -Match "Error"}

}
GregL
  • 9,370
  • 2
  • 25
  • 36
user312042
  • 83
  • 4
  • It sure seems like it should work. Are you getting any errors at all? Are all the servers online and reachable? Does `Get-Eventlog` work if you specify individual servers directly? – Zoredache Nov 20 '15 at 17:49
  • Consider rewriting as a workflow so you can leverage the parallel engine to speed up the process. – Colyn1337 Nov 20 '15 at 18:51
  • @Colyn1337 I agree this would be a great use case for a work flow, if and only if speed matters. – Eric Nov 20 '15 at 20:12

1 Answers1

3

I verified you script does work, there is a long lag time between connections. You just need to let it run and be patient.

Eric
  • 554
  • 1
  • 5
  • 15