I need to migrate some databases from one server to another to decommission the first one. This server is sharing a network share and a database. Prior to migration and to ensure data integrity, I need to avoid users connections to DB as well as network resources. How can I kick all users connections (and keep them disconnected) but administrator ones?.
Both servers are now DC in case this is important.
For the database you could issue these commands providing the accounts connecting to the database do not have db_owner privileges:
To log off any users connected via RDP you could query the connected users using:
...and a logoff with the listed IDs to logoff any connected user:
You can then disconnect any open smb sessions with:
I would then access the share permissions and remove any permissions after creating a screen shot of the settings. This will prevent new connections.
logoff
ortskill
commandsnet session \\<computer> /delete