XenDesktop 7 Rolling Reboot Script


RebootScript_Progress_Report

The below script will perform a rolling reboot of all Servers in a Delivery Group.

It starts by placing servers with no sessions in Maintenance Mode and rebooting them one by one. All servers with active sessions are placed in Maintenance Mode to prevent new sessions. Any servers in Maintenance Mode when the script was started are ignored.

To prevent “breaking” your delivery group, if all servers have active sessions a percentage of servers are “held” for reboot later in the script. Otherwise users would be prevented from logging on. This is 20% by default but can be configured using the –HoldPercent parameter.

Servers in Maintenance Mode do not allow new connections but allow users to reconnect to their sessions.

Virtual Servers are rebooted using Hypervisor, physical are rebooted via Windows OS. By default the script uses the Hypervisor.

Once all servers with no sessions are rebooted, the servers with active sessions are checked every 5 minutes to see if all sessions have cleared down. Once all sessions are logged off the server is rebooted and taken out of Maintenance Mode.

If any servers were "held" for reboot they are rebooted at the end.

The script will end after all servers are rebooted or it times out (24 hours by default). All servers are taken out of maintenance mode after reboot and again at the end of the script to make sure.

Status reports are written to screen and file during various stages of the script. The status report will list: All servers, whether pending, hold, or rebooted, reboot time, whether in Maintenance Mode, and session count.

Below are some ideas I have to add to future versions.

  • Multiple Desktop Group support
  • Verification of Parameters. I.E Does desktopgroup exist?
  • Verification of HoldPercent to prevent using higher than 90%
  • Start Rebooting Hold Servers when 50% of existing servers rebooted rather than waiting to end of script
  • Option to force reboot if remaining sessions are RDP.
  • Timeout in case session hosts don't register with controller.
  • Abort script if more than x fail to reregister with controller
  • Rebooting servers in groups rather than one by one.
  • Signed script

Disclaimer: Use this script at your own risk. All scripts should be tested on non-Production environments first. I have not tested this script in a large environment yet. Once I have my new lab up and running I will have more capcity to test this.

Full list of syntax and help is available by typing Get-Help  XD7_Rolling_Reboot_V1.ps1

XenDesktop 7 Rolling Reboot with PS1 Extension (267 downloads) XenDesktop 7 Rolling Reboot Unsigned with txt Extension (169 downloads)