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.
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.
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.
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.
Terminal Services Configuration UI (Administrative Tools -> Terminal Services -> Terminal Services Configuration) is the other way to configure TS server drain settings:
The UI shows the current status of the drain mode. Double-clicking “Terminal Server Drain Mode” brings up another dialog box:
The three settings listed are defined as follows:
Update: The settings are changing slightly:
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".
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
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?
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.