title: How to Return a Pretty Zero Value with the Count Property from Get-Process?
body: <p>Compare the three scripts below:</p>
  
  <p><strong>Sample 1</strong></p>
  
  <pre><code>$a = GPS | Where {$_.ProcessName -Match 'AcroRd32'}
  $a
  $a.Count
  
  If ($a.Count -Eq 0)
  {
      Echo "Adobe Reader is Off"
  }
  Else
  {
      Echo "Adobe Reader is On"
  }
  
  # If Adobe Reader is not running, how come 0 (zero) is not returned?
  # This is prettier, should I use it?  Or does it slow down performance?
  </code></pre>
  
  <p><br /></p>
  
  <hr />
  
  <p><strong>Sample 2</strong></p>
  
  <pre><code>$a = GPS AcroRd32
  $a
  $a.Count
  
  If ($a.Count -Eq 0)
  {
      Echo "Adobe Reader is Off"
  }
  Else
  {
      Echo "Adobe Reader is On"
  }
  
  # If Adobe Reader is not running, how come 0 (zero) is not returned?
  # This is uglier, but it doesn't have to pipe any output, so does it have any performance gains?
  </code></pre>
  
  <p><br /></p>
  
  <hr />
  
  <p><strong>Sample 3</strong></p>
  
  <pre><code>GPS AcroRd32 | Measure | Select -Expand Count
  
  # 0 (zero) is returned, but with an ugly Error
  </code></pre>
  
  <p><br /></p>
  
  <hr />
  
  <p>I guess part of my problem is that I'm treating PowerShell like it's VBS; writing code in this manner/style would usually yield me an integer value of zero and not throw any errors (if Adobe Reader was off, of course).  What's the <em>correct</em> PowerShell way of checking that an instance of a program is not running?  The performance questions in the comments are secondary to the "PowerShell Way" question.</p>
  
  <p>P.S.  To be honest, the Error Message returned by the 3rd Sample wouldn't break anything, it's just ugly, so it's not beyond practical use, so I guess the real problem is that I'm just a sucker for aesthetics =^D</p>