Virtual Apps and Desktops – VDAs will remain turned off after Restart Schedule

Have you ever experienced that some of the Virtual Desktop Agents remain turned off after a scheduled reboot via the Delivery Group? This is something I could notice several times of the last years in various environments. Most of the time this only affects a few machines and it is not a big deal. During a current customer engagement I could see the same issues again but sometimes over 40% of the VDAs have been affected (not every day). This can happen if there is a boot storm occurring (PVS servers are exhausted) or the VDA registration process is not happening after 20 minutes (CTX223434).  That was not the case in this specific environment. The interesting thing is that we never saw a power on action for the problem VDAs in VMware vCenter. You will find a lot of people in Citrix Discussions or Reddit who are struggling with the same problem but seems like there is not a real solution for this behavior.

That is why I came up with the idea to write a PowerShell script which needs to be run after the restart schedule which is doing the following things:

  • Checking for all faulty VDAs for the given Machine Catalog (PowerState: Off, RegistrationState: Unregistered, MaintenanceMode: False)
  • Powering on each VDA with a delay of 15 seconds (New-BrokerHostingPowerAction)
  • Sends an email notification (if enabled)

The great thing is we do not need to work with VMware PowerCLI, because we can start the VDAs with the integrated Citrix PowerShell SDK. This makes it work for all the environments out there, doesn’t matter if you are running Citrix Hypervisor, VMware, AHV etc.

Hope this is helping some people and I appreciate some feedback 🙂

Citrix_VDA_BootFix_V1.2.ps1

 

 

 

 

 

4 comments

  1. The script is working fine when I starting it in Powershell. But when I set it up as an Task Schedule is not working. Hav you tried to run the script from Task Schedule?

  2. Thanks.
    I had to set the Action in Task Schedule to:
    Action: Start a Program
    Program/Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Add arguments: -Executionpolicy bypass -file C:\thescript.ps1

    That did the trick.

    But it seems to run the script only work with Domain Admins role.

Leave a Reply

Your email address will not be published. Required fields are marked *