title: How do I use results of PowerShell's 'invoke-SQLcmd' in an 'if' statement?
body: <p>I can't figure out how to get the results of the query (qty_records) which is 5 so I can use it in a PowerShell If statement.</p>
  
  <p>====</p>
  
  <pre><code>$my_query = "select count(CustomerNumber) as qty_records from customers"
  
  $qty_records = Invoke-Sqlcmd -Query $my_query -ServerInstance "2008c" -Username sa -Password abc.1234 -Database MikeDB
  
  if ($qty_records -gt 4) {
      write-host "do something"
  } else {
      Write-Host "do something else"
  }
  </code></pre>
  
  <p>======
  thanks</p>