title: Powershell Item array not checking 0
body: <p>I am currently working on a PowerShell script that interacts with a SQL Server database, at one point I need to see if there is a customer by the same name in the table, as such I am running the following query from PowerShell.</p>
  <p>NB. <code>Invoke-SQL</code> is a helper function which calls <code>Invoke-SQLCMD</code> with specified parameters and allows database calls to be turned off with a global <code>$Testing</code> flag</p>
  <pre><code>$Customercount = Invoke-SQL &quot;SELECT Count(Cust_ID) FROM Customers WHERE Cust_Name LIKE '$CustName'&quot;
  </code></pre>
  <p>This correctly returns an object which can be read with <code>$Customercount.itemarray</code> however when this returns a 0 the matching fails as per the example below.</p>
  <pre><code>PS&gt; $CustName = &quot;Joe Bloggs&quot;
  PS&gt; $Customercount = Invoke-SQL &quot;SELECT Count(Cust_ID) FROM Customers WHERE Cust_Name LIKE '$CustName'&quot;
  PS&gt; $Customercount.itemarray
  0
  PS&gt; if ($Customercount.itemarray -eq 0) {Write-Host &quot;equals 0&quot;}
  PS&gt; if ($Customercount.itemarray -eq '0') {Write-Host &quot;equals 0&quot;}
  PS&gt; if ($Customercount.itemarray -eq &quot;0&quot;) {Write-Host &quot;equals 0&quot;}
  PS&gt; if ($Customercount.itemarray -eq $Null) {Write-Host &quot;equals 0&quot;}
  PS&gt; $CustName = &quot;Gael Test&quot; 
  PS&gt; $Customercount = Invoke-SQL &quot;SELECT Count(Cust_ID) FROM Customers WHERE Cust_Name LIKE '$CustName'&quot;
  PS&gt; $Customercount.itemarray
  1
  PS&gt; if ($Customercount.itemarray -eq 1) {Write-Host &quot;equals 1&quot;}     
  equals 1
  PS&gt; 
  </code></pre>
  <p>I feel like I am missing something fundamental here but I haven't been able to place it, can anyone shed light on what I'm missing</p>