title: Dropping Database in Powershell with Invoke-Sqlcmd tells me DB is in use even though it's not
body: <p>I am trying to drop a database like this</p>
  
  <pre><code>Invoke-Sqlcmd -Database Dbname-ServerInstance ".\SQLEXPRESS" -Query "drop database DbName;"
  </code></pre>
  
  <p>in a powershell script and I get this message:</p>
  
  <pre><code>Invoke-Sqlcmd : Cannot drop database "DbName" because it is currently in use.
  At line:1 char:1
  + Invoke-Sqlcmd -Database Dbname-ServerInstance ".\SQLEXPRESS" -Que ...
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  + CategoryInfo          : InvalidOperation: (:) [Invoke-Sqlcmd], SqlPowerShellSqlExecutionException
  + FullyQualifiedErrorId : SqlError,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand
  </code></pre>
  
  <p>The Database is not in use. What am I doing wrong?</p>