title: PowerShell: Monitor multiple server event logs every minute
body: <p>I am working on a PowerShell script that will monitor a list of servers every minute and trigger on a specified event. While my script isn't completed, this is what I have so far;</p>
  
  <pre><code>$TimeAgo = (Get-Date).addMinutes(-1)
  $servers = "server1","server2","server3","server4"
  
  foreach ($server in $servers) 
  {
      $events = Get-EventLog application -computername $server -after $TimeAgo
  
      foreach ($event in $events) 
      { 
          $event 
      }
  }
  </code></pre>
  
  <p>The foreach is doing it's job, I can see events from "server1" populate the screen, but then it locks up. It never quits server1 and it never moves onto server2. </p>
  
  <p>Any ideas on what's going on?</p>
  
  <p>For debugging, this works if I run it locally on the server:</p>
  
  <pre><code>$TimeAgo = (Get-Date).addMinutes(-1)
  Get-EventLog application -after $TimeAgo
  </code></pre>
  
  <p>It's when -ComputerName is introduced that I get a blinking cursor and it does not move onto the 2nd server in the list. </p>
  
  <p>Edit: It is working, it just takes about 6-7 minutes to complete the first server. This won't be ideal if I want to scan every minute. </p>