Closing Orphaned Sessions
An orphaned session is one that is no longer being used. An orphaned session can occur for a number of reasons. For example, if you do not limit users to one session and don't set a time limit for resetting idle and disconnected sessions, you might encounter sessions that were left open by users. You might also find orphaned sessions if users get disconnected from their sessions and you are not using the RD Connection Broker (which will reconnect users to disconnected sessions). In this instance, when the users reconnect to the farm, they might open a new session and unknowingly abandon the other session.
There are several ways to decrease orphaned sessions. You can configure Group Policy objects (GPOs) to end idle and disconnected sessions automatically after a certain period of inactivity, or you can use the RD Connection Broker to reconnect users to their disconnected sessions. However, if these avenues are blocked for you, you should know how to terminate orphaned sessions.
First, you must determine which sessions are really abandoned. A good way to tell if a session is not being used is to look for active and disconnected sessions that have been idle for a certain period of time, such as if you have shift workers and a session is idle for longer than the normal daily shift hours. Check the Users or Sessions tab of the Remote Desktop Services Manager or use the query user command to figure out which sessions to terminate by finding out how long sessions have been idle. For example, to check the Idle Time setting for all sessions on server FUJI, you can run the following command.
C:\windows\system32>query user /server:FUJI
USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME administrator console 1 Active none 7/26/2010 6:51 PM jimy.barr rdp-tcp#1 2 Active 57 7/30/2010 4:55 PM administrator rdp-tcp#0 3 Active . 7/27/2010 6:37 PM nancy.anderson rdp-tcp#2 4 Active 48 7/30/2010 4:55 PM kristin.griffin rdp-tcp#3 5 Active 7 7/30/2010 4:56 PM
NOTE: See the section entitled "Auditing User Logons" later in this tutorial for more examples of how to use the query user command.
The results will show the state, idle time (if applicable), and logon time of each session.
At this point, you have a couple of options: you can disconnect the session or terminate it. Disconnecting the session causes it to use fewer resources on the server while leaving open the applications and data in use in the session. Terminating the session (also called resetting the session) will end the session completely. Disconnecting is not invasive; users can get back to where they were by logging on again, but it does continue to use resources on the server. Terminating sessions frees resources, but it can lead to file locking issues because it's an ungraceful exit and files might not close properly.
NOTE: RDS does not support concurrent user licensing, just per-user or per-device. Therefore, if you're using a native RDS environment (and aren't running add-ons that are licensed on a concurrent-user basis), it's immaterial from a licensing perspective whether you disconnect or terminate a session. Adding third-party software that does support concurrent user licensing can affect the best practices that apply to you.
In this tutorial:
- Managing Remote Desktop Session
- Introducing RD Session Host Management Tools
- Command-Line Tools
- Connecting Remotely to Servers for Administrative Purposes
- Managing RD Session Host Servers from Windows 7
- Organizing Servers and VMs in the Remote Desktop Services Manager
- Monitoring and Terminating Processes
- Terminating Applications
- Monitoring and Ending User Sessions
- Closing Orphaned Sessions
- Disconnecting Sessions
- Providing Help with Remote Control
- Enabling Remote Control via Group Policy
- Enabling Remote Control via RD Session Host Configuration
- Shadowing a User Session
- Troubleshooting Session Shadowing
- Preparing for Server Maintenance
- Sending Messages to Users
- Shutting Down and Restarting RD Session Host Servers
- Applying RDS Management Tools
- Get the Server Names
- List Processes on the RD Session Host Servers
- Auditing User Logons
- Closing Unresponsive Applications