title: PowerShell try-catch isn't working
body: <p>I'm working on a script and want to check, if a taskname is existing.
  It looks so far like this: </p>
  
  <pre><code>try {
      Get-ScheduledTaskInfo -TaskName "taskname"
  }
  catch {
      echo "doesn't exist"
  }
  </code></pre>
  
  <p>When I run the code, it prints me the error message and not "doesn't exist":</p>
  
  <pre><code>PS C:\Windows\system32&gt; try {
      Get-ScheduledTaskInfo -TaskName "taskname"
  }
  catch {
      echo "doesn't exist"
  }
  Get-ScheduledTaskInfo : The system cannot find the file specified.
  At line:2 char:5
  +     Get-ScheduledTaskInfo -TaskName "taskname"
  +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : ObjectNotFound: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [Get-ScheduledTaskInfo], CimException
      + FullyQualifiedErrorId : HRESULT 0x80070002,Get-ScheduledTaskInfo
  </code></pre>
  
  <p>Does anybody has an idea why the catch phrase is not triggered?</p>
  
  <p>Thanks for any help!</p>
  
  <p>Best regards</p>