2

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.

5
  1. You can prevent new user connection using firewall(do not forget to leave an exception for administrator).
  2. Than you can close RDP sessions using logoff or tskill commands
  3. Than you can close opened smb sessions using net session \\<computer> /delete
7

For the database you could issue these commands providing the accounts connecting to the database do not have db_owner privileges:

ALTER DATABASE <dbname> SET OFFLINE WITH ROLLBACK IMMEDIATE;
go
ALTER DATABASE <dbname> SET ONLINE
go
ALTER DATABASE <dbname> SET RESTRICTED_USER
GO

To log off any users connected via RDP you could query the connected users using:

quser

...and a logoff with the listed IDs to logoff any connected user:

logoff <ID>

You can then disconnect any open smb sessions with:

net sessions \\<computer> /delete

I would then access the share permissions and remove any permissions after creating a screen shot of the settings. This will prevent new connections.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.