Just recently a customer that is on the move from XenApp 6.x to XenDekstop 7.x noticed that there’s no longer an option or policy to set a fine grained reboot schedule.

Thinking about it for a while I figured that all reboots are handled by the controller, and they are most likely initiated through the existing SDK, so putting together few lines of PowerShell should give us something to schedule.

Below is an example of how we can reboot VMs with a specific tag set in XenDesktop.

Using XenDesktop tags will allow us to set different reboot schedules for different XenApp instances, meaning we get a convenient flexibility even within the same group of servers:

 

param([string]$RebootTag)
Add-PSSnapin citrix*
Get-BrokerMachine | where {($_.PowerState -eq "on") -and ($_.Tags -contains "$RebootTag")} | ForEach-Object {
new-brokerhostingpoweraction -Action Restart -MachineName $_.MachineName
}

 

This script can, for example, be scheduled multiple times locally on the controller, each with a different tag specified as input parameter.

It is a simple but yet really usable example of how you can leverage the SDK to work around or add required functionality.