I’m working with a situation where all of the computers in a computer lab are actually zero-clients connecting to a dedicated Windows 7 VM on a server cluster.
This environment has its complexities, and I’m working to improve the performance.

That being said, I would get frequent notices from the Instructor that the computers would be running slow.

  • Rebooting the VMs would fix that, but it appeared that was just a Band-Aid.

I noticed that each VM would hold on to the disconnected RDP sessions and continue to consume resources in the background. Given that the Computer Lab terminals would RDP to a Windows 7 VM that was unshared, it was odd to me that more than one session would remain. I guess the users aren’t fully logging out of their sessions… This being a sensitive environment already, there were no resources to spare for these inactive sessions.

How do you terminate them automatically?

I started looking into a way to terminate the idle RDP sessions and found the perfect method through GPO. It has actually been around for years, but I can confirm it (still) functions in a Windows Server 2012 R2 environment with Windows 7 VMs.


Create the GPO:

In your group policy console, navigate to or create and link a policy that applies to your target computers (the hosts you would like to kill disconnected RDP sessions for)

Computer Configuration > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Session Time Limits

Open Session Time Limits and enable the following policy:

  • Set time limit for disconnected sessions

Once enabled, you’re allowed to select from a drop-down after how long you would like to end a disconnected session.

Apply the changes and go ahead on to test, or force group policy updates to those hosts.


How do I know it works?

I set the time to 1 minute and applied the GPO to a test VM.

I logged into this VM three times remotely and once from the console.


I decided to close the first of three RDP sessions, without logging off. Here it shows disconnected:

After a minute, to my delight, the session was gone!


So, I disconnected the other two sessions :

and confirmed they were terminated automatically as well:

As Apache would say:


It works!


After testing:

I chose to set the interval to 30 minutes:

I forced a group policy update on all of the VMs.

Now we won’t see masses of idle disconnected sessions consuming resources on our server cluster.



This will not work for physical/console sessions, only sessions over RDP. This is functional in the example environment because the only method for the user to access the workstation is via RDP protocol, and they mainly close their session without logging off.

Leave a Reply