title: How to count number of rows in a powershell variable
body: <p>I have the following powershell query :</p>
  
  <pre><code>$sql = "select name, lastName, City, Address from Persons"
  
  $TotalPeople = Invoke-Sqlcmd -ServerInstance $ResultsInstance -Database $ResultsDatabase -Query $sql
  
  Write-Output "Total number of people run is $TotalPeople  "
  </code></pre>
  
  <p>I want to be able to count the number of rows in the $TotalPeople variable. Is there a way to do this in powershell?</p>