One nice feature of Citrix XenDesktop is the ability to adjust the number of powered on desktops for Peak and Off Peak hours. This allows you to configure a different number of available powered on desktops based on time of day and day of week. This feature is sadly missing from VMware Horizon View. There is, however, a way to accomplish the same functionality using View PowerCLI.
For example, on a Connection Server, you can run the following View PowerCLI cmdlet Update-AutomaticLinkedClonePool to set the number of spares to 10 for the linked clone desktop pool “Desktop Pool”.
Update-AutomaticLinkedClonePool -Pool_id “Desktop Pool” -HeadroomCount 10
This will set the Number of spare (powered on) machines for the Desktop Pool to 10 and power on machines to meet this number up to the configured Max number of machines. So if there are 20 desktops in the pool and two people are logged in 10 additional desktops will be powered on and ready to accept connections. If another user consumes a desktop from the pool another desktop will power on to maintain the 10 spare powered on machines up until the Max number of machines is reached.
Run the command again with and specify the HeadroomCount to be 5. As long as the Remote Machine Power Policy for the pool is set to Power off then any spares over the HeadroomCount number will power down.
Update-AutomaticLinkedClonePool -Pool_id “Desktop Pool” -HeadroomCount 5
There are reasons why it is a nice to be able to increase or decrease the number spares in a pool, for example:
- Just prior to start of a shift to help improve user experience.
- To decrease the number of spares on a locally accessed pools on the evening or weekend and increase the number of spares available in pools used for remote access.
- Decrease spares in pools not used during a specific period of time to allow resources to be used for other pools.
Using View PowerCLI and the Windows Task Scheduler you can automate adjusting the spares up or down on a schedule.
Just use the code below to create a powershell script, Adjust-LCSpares.ps1, and save it on the Connection Server. I create a directory, C:\ViewPS, to store any of my scripts.
#Usage Adjust-LCSpares.ps1 -Pool <Pool_id> -SpareCount <Number> param( [string]$Pool, [string]$SpareCount ) #Load the View PowerCLI Snapin Add-PSSnapin vm* #Update the Linked Clone Pool specified with the SpareCount specified Update-AutomaticLinkedClonePool -Pool_id $Pool -HeadroomCount $SpareCount
The script takes the command line parameters -Pool and -SpareCount. This way I only need one script to adjust the number of spares up and down for any pool specified.
There isn’t any error checking in the script, it may be something I work on later. Things like making sure the command line parameters are specified, does the specified pool exist, or making sure the number of spares is not greater than the Max number of machines.
Now just create a Task in Windows Task Scheduler on the Connection Server. The Task needs to be configured to run as a user with the Inventory Administrator role in View Administrator. The task will need to be set to Run whether the user is logged on or not.
For the task action set the Action to Start a Program, the Program/script to PowerShell, the Add arguments to “.\Adjust-LCSpares.ps1 -Pool ‘Desktop Pool’ -SpareCount 10”, and the Start in to the directory where the Adjust-LCSpares.ps1 is located.
Set Task Triggers to the desired schedule. For example Daily at 7:45 AM (Just before people start arriving at 8).
Follow the same process to create another task which then reduces the number of spares needed at say 8:30 AM after a majority of people working have logged in or you could want to keep the same number of spares through out a shift and reduce the number at 5:30 PM after everyone is gone.
The Update-AutomaticLinkedClonePool cmdlet works on linked clone pools. To change the number of spares for a full clone pool use the Update-AutomaticPool cmdlet.
Update-AutomaticPool -Pool_id “Desktop Pool” -HeadroomCount 10
A bit more complex than the way it is done with XenDesktop, but the end result is the same.
View PowerCLI is installed as part of the Connection Server installation. Documentation for using View PowerCLI with Horizon View 6 can be found here.