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