Citrix Blogs

XenApp & XenDesktop 7.x Server OS VDA Staggered Reboot Framework

This is the second version of the reboot framework for XenApp/XenDesktop Server OS VDAs. If you’d like a refresher on the first version, please revisit our previous blog post.

First, I’d like to summarize the framework conditions:

Now, let’s have a closer look at the 2nd version of the framework:

Despite slightly different configuration parameters, the main difference between the first and the second version of the framework is the support of all provisioning methods offered by XenApp and XenDesktop. While the first version has no support for Machine Creation Services (MCS), the second version now has support for all provisioning methods including MCS.

The following changes and enhancements where made compared to the first version:

Since MCS provisioned VDAs require the reboot to be initiated by a Delivery Controller in order to reset the cache disks, this version of the reboot framework leverages the XenApp and XenDesktop SDK instead of RDS PoSH Cmdlets. Hence, this version supports all of the Server Operating Systems XenApp and XenDesktop maintain.

Note: There is no requirement to install the SDK on the VDA, since every VDA will establish a remote PoSH connection to the Delivery Controller the VDA is registered with. However, this approach requires a service account to allow the VDA to execute maintenance tasks like enabling maintenance mode, sending user messages and rebooting machines.

The framework contains three (3) scripts

1) CreateAESKey.ps1

Since a service account is required for this script to initiate a remote PoSH session with a Delivery Controller, a password is required, as well. To avoid saving the password in plain text within the script, I’m providing a script to create an encrypted password for the service account.

The “CreateAESKey” script will create a key to encrypt the password. The key is saved in a dedicated key file within the root directory of the script.

2) CreateAESPassword.ps1

The “CreateAESPassword” script will use the key file created with the “CreateAESKey” script, to encrypt the password. The password is saved in a dedicated password file within the script root directory.

3) FMAServerOSVDAReboot.ps1

The second version of the reboot framework. The script requires the key and the password files described above. Both files are expected to be stored in the framework script root directory. However, file paths can be changed within the code of the script. The service account name is specified within the code as well.

Note: Both files, the password file and the key file, allow decryption of the service account password. Hence, I highly recommend to limit access to both files through NTFS file permissions. Furthermore, Microsoft Windows file access auditing policies can be configured to further enhance security for both files.

The following tasks are performed by the reboot script:

Note: Each VDA reads the Delivery Controller information from the registry to spread load across all Controllers of the site. Every time a remote PoSH command needs to be launched, a remote session is established with the Delivery Controller and closed after sending the command.

Now, let’s cover the requirements of the framework

The following minimum permissions within the XenApp / XenDesktop site are required for the service account, to perform the Server OS VDA reboots:

As mentioned earlier, each VDA initiates a remote PoSH session with the Delivery Controller the VDA is registered with. Please note, that by default, the maximum number of remote sessions is limited by Microsoft. To address this limit, I introduced a random delay prior initiating the remote session to better spread the load of the VDA server groups on the Controllers. However, larger environments might require to increase the allowed number of remote sessions on the Controllers. In addition to that, Microsoft also uses an overall limit for all remote sessions as well as a quota for each shell plugin. Depending on which limit has the smaller number, that limit will apply. So please make sure, to set all limits accordingly. Please find an example on how to set the limit to support up to 100 remote sessions:

To allow remote PoSH sessions, the service account needs proper rights on the Delivery Controller:

Finally, let me provide some details regarding deployment and configuration:

I personally prefer to deploy files – in this case the script, key and password file – with Group Policy Preferences (GPP). This ensures that each VDA downloads the current version of the script from a central share.

Modifying the membership of the Delivery Controllers “Remote Management Users” group can be achieved by GPP easily.

The task scheduler can be configured through GPP as well. By using the targeting mechanism of GPP, it is possible to use a single GPO to assign the different schedules to the appropriate VDAs. The cool thing about targeting, it’s quite flexible. For example, you can use Organizational Units (OU) or Active Directory Security Groups to assign the proper scheduler to a server Group.

Example action without forced logoff:

“C:WindowsSystem32WindowsPowerShellv1.0powershell.exe” -ExecutionPolicy RemoteSigned -File <path to script> -FirstMsgDelay 600 -MsgDelay 600 -RebootDelay 300 -ForceLogoff 0 -ImidiateRestart 0

Example action with forced logoff:

“C:WindowsSystem32WindowsPowerShellv1.0powershell.exe” -ExecutionPolicy RemoteSigned -file <path to script> -RebootCycle 3600 -FirstMsgDelay 600 -MsgDelay 600 -LogoffDelay 300 -RebootDelay 300 -ForceLogoff 1 -ImidiateRestart 0

Script command line parameters:

Script parameters (need to be set within the code):

The script can be downloaded here.

Hope this might be useful for you as well.

Until next time!

Robert Woelfer
Principal Consultant | Citrix Consulting Central and Eastern Europe

P.S.! So we can satisfy the legal guys:
Disclaimer Notice
This software / sample code is provided to you “AS IS” with no representations, warranties or conditions of any kind. You may use, modify and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the software / sample code may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the software / sample code fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the software / sample code. In no event should the software / code be used to support of ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SOFTWARE / SAMPLE CODE, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Although the copyright in the software / code belongs to Citrix, any distribution of the code should include only your own standard copyright attribution, and not that of Citrix. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the code.

Exit mobile version