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"}
}