Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Force Invoke-SQLCmd connection closed

$
0
0

I am writing a PS script that calls several SQL statements against an instance using Invoke-SQLCmd.  One of those SQL statements restores a database; however, the previous query connections remain open and the restore fails with an access denied message.  I need to forcibly close the existing connections to the instance (there will be more than one) prior to running that section of the script.  All I can find online is SMO programming or ADO, both of which add overhead and complexity to the script.  I'd like to use Invoke-SQLCmd.  Is there any way to forcibly close the connections it creates? 

Thanks 


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>