Home Forums Programming Powershell invoke-sqlcmd and stolen single user session RE: invoke-sqlcmd and stolen single user session

  • SQLPirate - Thursday, October 12, 2017 8:24 AM

    Have you tried putting your connection in the database first? Either with a USE statement or changing your Invoke-Sqlcmd -Database parameter to specify the appropriate database instead of 'master'.

    I did test this with SSMS, I didn't find that I need to be using the single_user database to reserve it for the session. Even if I was using master, single user db was reserved for that session, couldn't connect from another session.