Lets say we have a Windows 2008 server and there are 4 users (A,B,C,D) logon. If User "B" disconnects from the session ('broken connection'), how can we automatically log off User B? I've searched and we can use 'Remote Desktop Session Host Configuration' to setup disconnected users to log off, but it applies to every/all users. How can we make that rule applicable to a specific user?


Create a scheduled task that runs a powershell script

Get-TSSession -State Disconnected -UserName userName |  Stop-TSSession -Force

Or just group all such users into a dedicated server...


Go to Computer Management, click Local Users and Groups, find your username, and click Sessions tab. From there, you set the different options.

  • Side note: This will not work with a domain environment. Users will not show up in the Local Users on the server if logged in as a domain users. You would have to do this through the Active Directory Users & Computers snap-in. I would prefer this method over the scheduled tasks/powershell because you would be forced to manually code every username into the script. Even on a small domain this could get arduous. – Travis Oct 20 '15 at 21:03

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.