title: Use Invoke-SQLCmd and return number of rows deleted/affected
body: <p>I have a very simple powershell command, where $query is just "delete from mytable"</p>
  
  <pre><code>Invoke-sqlcmd -ServerInstance $databaseserver -Username $databaseuser -Password $databasepassword -Database $databasename -Query $query| Out-File -filePath $output
  </code></pre>
  
  <p>However, this does NOT output the number of rows affected?</p>
  
  <p>The equivalent in SQLCMD <strong>does</strong> output the no rows affected:</p>
  
  <pre><code>&amp; sqlcmd -S . -U $databaseuser -P $databasepassword -Q $query    -o $output
  </code></pre>
  
  <p>Is there any way to get <code>Invoke-sqlcmd</code> to return the number of rows?</p>