title: How to timeout PowerShell function call
body: <p>I wrote a little powershell function that executes Get-EventLog against remote servers. On some servers this seems to just hang and never times out. Can I timeout a powershell function call? I see how to do this against a <a href="https://stackoverflow.com/questions/1747696/run-a-program-from-powershell-with-timeout">different process</a>, but i want to do this for a power shell function.</p>
  
  <p>thanks</p>
  
  <pre><code>#######################
  function Get-Alert4
  {
      param($computer)
      $ret = Get-EventLog application -after (get-date).addHours(-2) -computer $computer | select-string -inputobject{$_.message} -pattern "Some Error String" | select-object List
      return $ret   
  } #
  </code></pre>