Many times users connect to remote Windows systems, do work, and close the remote session without properly logging off the account. In that case, multiple applications, which are still running with that login session use system resources. Sometimes it causes a slow response of our servers and creates pain for us. So this will be good to auto log off disconnected sessions from the Windows system.
This tutorial will help you to log all the disconnected remote sessions on the Windows system. This tutorial has been tested with Windows Server 2019.
Setup Auto Log Off Disconnected Sessions
We are making changes in the Local group policy of systems. So be careful with the changes.
First of all, open the ‘Group Policy Editor‘ on your server. Start run window by pressing “Win + R” and type gpedit.msc
on run window.
The local group policy editor will be opened on your system. Then navigate to the following location as the below-given instructions:
Local Computer Policy => Computer Configuration => Administrative Templates => Windows Components => Remote Desktop Services => Remote Desktop Session Host => Session Time Limits
You will find a list of options on the right side. Then Double click on “Set time limit for disconnected sessions” to open it.
By default, it is set to the ‘Not configured’. Change this to ‘Enabled’. Now you will see the option “End a disconnected session” on the lower-left side. Set this value to the desired time. I have set this to 1 hour, so any disconnected user is logged off after 1 hour.
Conclusion
In this tutorial, you have learned to configure your Windows system to auto log out disconnected remote sessions.
9 Comments
Hi, do you have a set of instructions to set this up for WVD?
I created this GPO on my domain controller and linked the GPO to Servers OU and in security filtering set to Authenticated users. However it doesnt seem to be working, As far as I know it will only work for new connections when users RDP to servers. So existing RDP disconnected users I have logged off via a PowerShell script. Any help will be appreciated thanks
GPO Details:
Computer Configuration (Enabled)
Policies
Administrative Templates
Policy definitions (ADMX files) retrieved from the central store.Windows Components/Remote Desktop Services/Remote Desktop Session Host/Session Time Limits
Policy Setting Comment
End session when time limits are reached Enabled
Set time limit for disconnected sessions Enabled
End a disconnected session 8 hours
User Configuration (Enabled)
No settings defined.
I have a feeling it is for new sessions. If there are existing ones when the policy gets applied, they likely have to be kicked, then the next time they log in the policy will take effect. That said, I’d like to see your PS script for logging off disconnected users.
You may want to look at loopback if you’re wanting to apply computer settings to the members of a user group.
So much thank you. I can’t find solution.
Great set of instructions, many thanks Rahul.
Hello,
It seams this not work to me. I’ve set the time to 10 minutes and running command gpupdate /Force but no user logoff.
What would this be for? Is this for people using RDP?
Yes