XenApp server – drain mode maintenance

//XenApp server – drain mode maintenance

XenApp server – drain mode maintenance

Share this post

The purpose of this article is to summarize the different ways an administrator can use to take a XenApp server offline for maintenance.

Drain-mode maintenace

TS Server Drain Mode was introduced in Windows Server 2008 and when the server is switched to Drain Mode, it does not accept any new connections but it will allow 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. Drain mode also allows server admins to connect to the console session – using “mstsc /admin”.

Administrators responsible for enterprise environments that is shared by multiple users will find the functionality of drain mode maitenance as very important feature. The most common scenario when drain mode maitenance can be used is when a single server is hosting applications for multiple users. Using this feature administrator can leave existing sessions active, including the ability to reconnection to disconnected sessions but block or redirect all new incoming requests to another servers hosting the same resources. Once all existing sessions are closed administrator can start maitenance tasks.

XenApp maintenance methods

Server administrators can put XenApp server in maintenance mode using:

Windows Remote Desktop Services options

Server administrator can manage incomming sessions using change logon command. This method can be used only when server is online. Logon mode for RDP is per-server configuration that is stored in registry in two different locations:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\TSServerDrainMode
0 = Allow all connections
1 = Allow reconnections, but prevent new logon until reboot
2 = Allow reconnections, but prevent new logon

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\WinStationsDisabled
0 = Enabled
1 = Disabled

Available change logon switches are the following:

TS change logon

XenApp  Logon control options 

Citrix strongly recommends that you use these method  instead of the Windows Remote Desktop Services options to control logons to XenApp servers.

Prior to version XenApp 6.5 the most common method was to use  Custom Load Evaluator that will report a full load when assigned to a server. The main reasons to use Load Evaluator were:

  1. Load Evaluator assigment is stored in data store, so Load Evaluator can be assigned to a server, even while server is offline.
  2. Load Evaluator will reject new sessions, but it will allow user to reconect to disconnected session
  3. Load Evaluator will affect only ICA sessions and RDP connection will still be allowed

In XenApp version 6.5 ability to directly assign Load Evaluator to specific servers was removed, instead Load Evaluator can be assigned to the Worker Group (Worker Groups are collections of XenApp servers, residing in the same farm, that are managed as a single unit). The ability to put a single server into maitenance mode is provided by logon mode control.

By default, logons are enabled for each server in a farm, allowing connections, reconnections, and session sharing. Before taking a server offline, such as for maintenance, use these options to reroute logons to other servers.

  •  Allow logons and reconnections. Enable all logons, reconnections, and session sharing (default setting).
  • Prohibit logons and reconnections. Reroute all logons, reconnections, and session sharing to other servers.
  • Prohibit logons only. Reroute new connections and session sharing, but allowing users to reconnect to disconnected sessions. This state persists until you change it manually.
  • Prohibit logons until server restart. Reroute new connections and session sharing, as above, but after restarting the server, the setting automatically changes back to Allow logons and reconnections.

logon control


XenApp logon control is actually managed through data store and is updated on target host using LHC synchronization (Local Host Cache). When system administrator change the logon mode in console, this change is actually not immediately done in the registry of the target machine. Behavior will be different based on the server status:

  • XenApp server is online – server will get notification using the normal LHC synchronization interval.
  • XenApp server is offline – server will get notification from data store during boot and automatically apply the logon mode that was configured in the console. This allow to change logon mode, even while server is offline.


Powershell scripts

Administrators responsible for large and dynamic enterprise environments, will look for methods to automate the XenApp server maintenance process. To fully manage and automate assignment of logon modes, there are two commands that can be used:

To get logon mode assigned to server, it’s one of the properties of the regular server object:
$(Get-XAServer -ServerName $Server).LogonMode

To assign logon mode to server:
Set-XAServerLogOnMode -LogOnMode $LogonMode -ServerName $Server

Values allowed for $LogonMode are the following:

  • AllowLogOns
  • ProhibitNewLogOnsUntilRestart
  • ProhibitNewLogOns
  • ProhibitLogOns



Important items to remamber:

  • In XenApp versions prior to 6.5 usage of custom load evaluator was just a workaround to provide required functionality. Logon mode functionality availabe in version 6.5 is a wining option and there is no reason to use the old approach.
  • System administrators still have RDP access to disabled servers to perform administrative tasks using mstsc /admin command.
  • Since logon mode is managed through data store, it is possible to drain server, even while server is offline.


Related Posts:

How to migrate a XenApp 6.5 Data Store to a new SQL server

Citrix Multistream ICA explained

XenApp 6.5 Performance Counters

XenApp 6.5 load values explained


By | 2016-12-18T19:21:39+00:00 December 13th, 2013|XenApp|2 Comments

About the Author:

I’m a Citrix Architect with 17 years experience in Microsoft and Citrix infrastructure. I have been working with Citrix since Metaframe 1.8 and my primary focus is on Server, Desktop and Application virtualisation with a preference for Citrix products. I’m an enthusiast of Citrix XenDesktop and Provisioning Server.


  1. Shah October 8, 2015 at 7:37 am - Reply

    In citrix xenapp 6.5
    If citrix environment server goes down where they user are already login or landed so they are unable to access for his session and when they are try to re-login at same time it will be not possible to login on a same server b/c the server goes down
    So I want
    When they users are going to re-login they are login another sever which I already publish in citrix app center.

Leave A Comment

To protect our website from spam. * Time limit is exhausted. Please reload the CAPTCHA.