Introducing Terminal Services Server Drain Mode

Introducing Terminal Services Server Drain Mode

  • Comments 16

 

When a terminal server needs maintenance, the administrator may want to prevent users from logging onto a server which is about to be taken offline. In Windows Server 2003 there was a command-line tool to disable all remote connections; however, this prevented users with disconnected sessions from reconnecting, causing them to lose their work. To address this issue, in Windows Server 2008, the TS Server Drain Mode prevents new users from logging onto the server, while allowing currently logged on users to reconnect to their existing sessions. By waiting for existing users to save their work and log off, the administrator can take a terminal server down for maintenance without causing user data loss. Additionally, TS server drain mode is integrated with Session Broker Load Balancing, allowing one of the servers in a load balanced farm to be safely taken offline without any perceived change to end user experience or loss of service.

What is TS server drain mode?

In Windows Server 2008, when a Terminal Server is in drain mode, remote logons for new users are disabled. Users with an existing session may reconnect (in order to save their work and logoff). Users without an existing session are prevented from logging on.

In a farm where Session Broker Load Balancing is deployed, users without an existing session are redirected to another server in the farm where they can logon. For servers not joined to a load balanced farm, if a user without an existing session connects remotely (i.e. attempts to logon), he will receive the error message shown below:

Additionally, there is an option to enable drain mode temporarily. When set, user logons are re-enabled automatically after restart. This option is convenient for applying simple patches that only require a single reboot.

While a server is in drain mode, administrators may still log on to the physical console or remotely log on using the /admin or /console command-line option for MSTSC. This allows administrators to remotely maintain the Terminal Server.

How to put a terminal server into drain mode?

There are two ways an administrator can put a terminal server into drain mode: 1) using the command-line tool chglogon.exe, or 2) using Terminal Services Configuration UI.

1. Command-line settings

The command-line tool chglogon.exe (or “change logon”) may be used to configure the drain mode. There are five options: /QUERY, /ENABLE, /DISABLE, /DRAIN, /DRAINUNTILRESTART, as shown in the following screen shot:

By default, all connections are allowed on a terminal server. To configure a server into drain mode, use the /DRAIN option.

To configure a server into drain mode temporarily, use the /DRAINUNTILRESTART option. After restart, user logons will automatically be re-enabled:

To take the server out of drain mode and restore connectivity, use the /ENABLE option:

The “chglogon /DISABLE” command has the same behavior as in Windows Server 2003 – no remote connections will be allowed, even if a user has an existing session.

2. Terminal Services Configuration UI

Terminal Services Configuration UI (Administrative Tools -> Terminal Services -> Terminal Services Configuration) is the other way to configure TS server drain settings:

tsconfig_UI_1.jpg

The UI shows the current status of the drain mode. Double-clicking “Terminal Server Drain Mode” brings up another dialog box:

tsconfig_UI_drain.jpg

The three settings listed are defined as follows:

  1. “Allow new user logons” – All remote connections are allowed
  2. “Deny new user logons” – Terminal Server is in drain mode
  3. “Deny new user logons until restart” – Terminal Server is in drain mode until the server is restarted

Update: The settings are changing slightly:

  1. “Allow all connections” – All remote connections are allowed
  2. “Allow reconnections, but prevent new logons” – Terminal Server is in drain mode
  3. “Allow reconnections, but prevent new logons until the server is restarted” – Terminal Server is in drain mode until the server is restarted

Also, the above blog post is accurate for Longhorn Server Beta3. There is a minor change for RC1 in the TsConfig UI – now the drain mode is called "user logon mode".

Leave a Comment
  • Please add 2 and 1 and type the answer here:
  • Post
  • PingBack from http://blogs.msterminalservices.org/conger/2007/06/15/terminal-services-server-drain-mode/

  • When a terminal server needs maintenance, the administrator may want to prevent users from logging onto

  • When a terminal server needs maintenance, the administrator may want to prevent users from logging onto

  • When a terminal server needs maintenance, the administrator may want to prevent users from logging onto

  • Is it actually useful to post screenshots showing the failure of a command to run because the server doesn't have the appropriate role installed? Why not just tell us the command and skip the pointless screen shot?

  • Is there a WTSxxx API for putting a server in drain mode?

  • Is there a WTSxxx API for putting a server in drain mode?

  • This has changed in RDS, my server keeps going into drain mode after a reboot and the only way to fix it is the cmd. I am unable to find the UI settings for drain mode.

  • look at RD Session Host Configuration mmc (tsconfig.msc) UI and it's in the lower portion of the mmc under general settings (user logon mode).

  • Mine is grayed out and I can't change the option.  When I try to use the drain mode command, it says it is ENABLED and set via group policy and cannot be changed.  How do I change this one?

  • I have the same issue Chris. Did you find a solution?

  • I am having the same issue with it being grayed out and saying controlled by gp. Anyone ever figure this out?

  • Has someone the solution for this problem?

    It is stil a big problem. The CIO is asking me every day for a sloution.

  • @Chris: Do you mean this error, from "chglogon /drain": Connections are currently ENABLED by Group Policy for this machine, unable to change.?

    This corresponds to the group policy "Allow users to connect remotely using Terminal Services".  If it's set, then you can't change drain mode.

  • Right click the Command Prompt and select Run as administrator.  Then run the appropriate command line.

Page 1 of 2 (16 items) 12