I have a Citrix farm and have written the below PowerShell script to automatically reboot the servers when there are no active connections.


The script would need to be scheduled to run on a Citrix server with the XenApp PowerShell SDK installed https://www.citrix.com/downloads/xenapp/sdks/powershell-sdk.html

I have setup a scheduled task than runs every hour during none business hours.

Citrix Reboot Script - TriggersCitrix Reboot Script - Actions


EXCLUDESERVERS A comma separated list of Citrix servers to exclude from the reboot routine.
REBOOTTHRESHOLD How many days of uptime before a server should be considered for a reboot.
MAXACTIVESESSIONAGE The maximum time in hours a session is allowed to be active. Any users with an active session over this time will get a 5 min warning and a message before the server reboots.

The Script