Create multiple VDA restart schedules in XenApp & XenDesktop 7.12

Since the introduction of FMA, VDA restart schedules in Citrix Studio have been very limited allowing for one schedule either once weekly or else daily at one specific time with the option to restart half the Delivery Group between two different times.

Now with XenApp and XenDesktop 7.12+ we can use PowerShell to create multiple restart schedules. This is great because it gives us back most of the flexibility we had with scheduled restarts of machines back in XenApp 6.5 using Worker Groups for example. You may not want to restart all VDA’s in a Delivery Group every night or once weekly, so we can turn to PowerShell to configure it how we want. Another new feature of 7.12 called tag restrictions allows you to splice up Delivery Groups so that only certain machines are restarted during different times.

It is important to understand how restart schedules work in XenApp and XenDesktop 7.x.

When you set a Delivery Group to restart on a schedule, you specify a start time and time you want the restart schedule to complete by, for example within 2 hours. This means if you have 20 VDA machines, with a reboot schedule time of 2:00am, all machines should be restarted by 4:00am. What actually happens is the Delivery Group is split in to two separate groups, Group1 and Group2 for example. The reboot schedule duration time is also divided by the amount of machines in a Delivery Group. In this case, that is 120 minutes divided by 20 which equals to 6 minutes. This means, one VDA is rebooted every 6 minutes. Those machines in Group1 are preferred for reboot, because they have fewer action sessions, and are not in maintenance mode for example. If you are using tags for reboots (XenApp/XenDesktop 7.12+) then those machines that have the correct tag are split in to groups and restarted based on calculated preference. When a machine is rebooted, a reevaluation of the preferred VDA to reboot next is performed so that the best placed VDA for reboot at that time is always chosen.

When a Delivery Group reboot schedule commences, all machines in the first phase are put in to drain mode that prevents new sessions from being launched. Keep in mind that existing sessions are reconnected. Also keep in mind that machines in phase 2 are available for new connections until phase 1 has completed the reboot cycle. When phase 1 is complete, those machines are taken out of drain mode and allowed to accept new connections. At this stage, phase 2 VDAs are placed in drain mode and the same process occurs.

To read up on power managing VDA’s including powering off VDA’s after log off etc. see http://www.jgspiers.com/xendesktop-xenapp-power-management/

To configure restart schedules we use the RebootScheduleV2 PowerShell cmdlets which are new with XenApp & XenDesktop 7.12.

To get started using a Delivery Controller launch PowerShell and add the Citrix PowerShell snapins using command asnp citrix.*The Citrix.Broker.Admin.V2 module contains all the cmdlets we need to configure scheduled restarts. The cmdlets with V2 on the end are the new cmdlets we will use to confiure flexible restarts. The original commands (which Studio reads) are Get-BrokerRebootCycle for example. If you create a reboot schedue within Studio it simply runs the non-V2 cmdlets in the background. For an example, I have created a simply daily reboot schedule using Citrix Studio. When you run the Get-BrokerRebootSchedule command the schedule job appears including the Delivery Group (DesktopGroupName), the frequency of reboots and scheduled start time etc.When you run the new cmdlet Get-BrokerRebootScheduleV2 notice my reboot schedule appears here aswell but there are some additional parameters that can be used such as RestrictToTag. For now I will delete the current reboot schedule so we can start fresh.As mentioned before to get granular with reboot schedules we can use tags. You assign tags to one or more VDA machines, and then create reboot schedules within PowerShell and link the schedules to your tags. Right-click a VDA and select Manage Tags. No tags have been created yet so click Create. Enter a name and description then click OK. Your tags could be department tags or anything else that makes it easy for you to understand and identify. Click Save. Now that we have one VDA using the HR tag, I can create a reboot schedule. The command I am using is New-BrokerRebootScheduleV2  -DesktopGroupUid 1 -Frequency Weekly -Name WeeklyRebootSchedule-HR -RestrictToTag HR -StartTime 01:00:00 -RebootDuration 0 -WarningDuration 15 -WarningMessage “Please log off as this machine will restart in 15 minutes”.

This means any VDA with a tag of HR (VDA1) will restart weekly on a Sunday at 1AM. A warning message will be given 15 minutes before restart. No further warning will be given.

Note: To find out the UID of a Delivery Group run command Get-BrokerDesktopGroup | fl name, uid

Note: Instead of using -DesktopGroupUid you can use -DesktopGroupNameI have added a new machine (VDA2) to the same Delivery Group. This time I will use a different tag so click Create. Enter a name and description. Click OK. Click Save. This machine (VDA2) will have a tag of IT. You can see VDA1 and VDA2 with different tags. I will now create a reboot schedule for the VDA’s carrying an IT tag. This reboot schedule is daily at 3AM. When you look in Studio, nothing shows under Restart Schedule because Studio cannot read the V2 cmdlets (xxx-BrokerRebootScheduleV2). And that is us done. Using command Get-BrokerRebootScheduleV2 both reboot schedules show. VDAs within the same Delivery Group will now have their own restart schedules. When a machine restarts (reboot schedule in progress) the Active parameter changes to True. The Citrix Broker Service reports a successful power action was achieved for VDA2 during it’s scheduled reboot. The GroupReboot for Delivery Group NewWS2012R2 has successfully completed. Notice how only one machine was processed even though there are two machines in the Delivery Group. That is the power of tagging and restart schedules. Another example use case could be a situation where you do not want to restart all Delivery Group VDA’s once per week, and once per day is too often. Maybe you would like to restart every Monday and Friday. This is possible by simply creating two reboot schedules, one for Monday and one for Friday as shown below. I have not used tagging so these schedules apply to all Delivery Group members.

 


10 Comments

  • Holger

    April 18, 2017

    Hi George,
    thanks for this detailed article. I have

    Reply
    • Holger

      April 18, 2017

      damn… too fast… 😉
      I wanted to write the following: I also configured some new Reboot Schedules with different tags. In my cases the reboots only worked with no user logged on.
      If any user is logged on they will get the defined message – but a reboot does not take place.

      Can you confirm this behaviour? Is this intended?

      Thanks,
      Holger

      Reply
      • George Spiers

        April 18, 2017

        Hi Holger

        Are you using 7.12? There is an issue in 7.12 where reboots do not process if a notification message is set. Citrix released a hotfix (LC6766) and the issue is resolved in 7.13

        Reply
        • Holger

          April 19, 2017

          Yes, I’m using 7.12 and I knew that there is an issue with reboots – but I thought that only it only appears when using the GUI or the old powershell scripts.

          Thank you!
          Holger

          Reply
  • Karthik

    May 8, 2017

    Hello

    Can we create Custom reboot schedule, afetr 14 days machine to be rebooted.Please update can we update the same in restart policy.

    Reply
    • George Spiers

      May 8, 2017

      No you can do a maximum of one week.

      Reply
  • Sarj

    June 28, 2017

    Do you need to create separate reboot schedules for each delivery group or can one schedule be applied to all delivery groups and managed via tag?

    Reply
    • George Spiers

      June 28, 2017

      Yes you need separate schedules for each DG.

      Reply
  • Srini

    August 3, 2017

    Hi George,
    I would like to create weekly reboot schedules (one for each day), will I be able to use the reboot schedules across multiple delivery groups or they are restricted to single delivery group?

    Reply
    • George Spiers

      August 3, 2017

      You need separate reboot schedules for each Delivery Group, so no sharing is allowed.

      Reply

Leave a Reply