title: PowerShell: get-eventlog takes too long to complete
body: <p>I am trying to script the review of the past 30 days of the Application and System Event Logs on remote servers, looking for only Warnings, Errors, or Critical entries.</p>
  
  <p>Borrowing from what I have found here and in other forums, I have come up with:</p>
  
  <pre><code>$Date = Get-Date
  $Range = $Date.AddDays(-30)
  $Range = $range.ToShortDateString();
  $LogName = Read-Host "Which Log? (Application, System)"
  $Server = Read-Host "Please Enter Server Name"
  
  get-eventlog $LogName -ComputerName $Server -After $range | where {$_.EntryType -eq "Error" -or $_.EntryType -eq "Warning" -or $_.EntryType -eq  "Critical"}
  </code></pre>
  
  <p>This seems to run fairly quickly, but then hangs several (5-10+) minutes before returning to a prompt, if it does....</p>
  
  <p>Note: if I remove the code:</p>
  
  <pre><code>-After $range
  </code></pre>
  
  <p>I can simply break the output with ctrl-c and get on with my day, but I'd rather it run as intended and then stop...</p>
  
  <p>So:  Any ideas on how to eliminate this hang?<br>
  I am also open to ideas on how to make the code more elegant (and faster)!
  And I wouldn't mind the script checking both the Application and System logs without having to run twice....</p>