Horizon PowerCLI: Modify existing Pool Settings in Horizon View

Earlier this year, I inherited several Horizon View environments that were not built with manageability in mind. I am working on a larger project to conduct a proper plan and design and rebuild these environments, but until that is complete I need to continue to support the legacy installations.

In these environments (Horizon 7.5.1), each user has its own manual pool which contains a single Windows 10 VM. There are 9 separate Horizon environments across different security zones This means each user has 9 manual pools and 9 desktops. We have approximately 75 users in each security zone, which gets us to just short of 700 manual pools across the 9 independent view blocks.

Ideally, we’d move all of the existing desktops into a new manual pool, and configure the pool settings one time in each zone, but for now, I have chosen to change the settings on the existing pools with PowerCLI for Horizon.

There are a few configuration items we need to change:

  1. Do not allow a user to select their Display Protocol
  2. Enable the “Allow user to reset their desktop” setting in all pools
  3. Change the maximum number of monitors from 1 to 2
  4. Disable Horizon HTML Access
  5. Set the View storage accelerator blackout time parameter

Working with Horizon PowerCLI and directly with the View API is not easy, it took me quite a bit of time to wrap my head around it.

Disclaimer: As always, be comfortable with the commands before running them in a production environment! I suggest thoroughly testing scripts that perform bulk actions like these in a lab environment.

The following steps assume that you already have the VMware PowerCLI modules installed from the PS Gallery.

First, you’ll need to obtain the “VMware.Hv.Helper” PowerShell module

https://github.com/vmware/PowerCLI-Example-Scripts/tree/master/Modules/VMware.Hv.Helper

Next, import the module by running “import-module VMware.HV.Helper.psm1″ from the directory you downloaded it to, or by copying the 3 files to C:\users\%username%\Documents\WindowsPowerShell\Modules\VMware.Hv.Helper” for a more permanent solution.

Now we’ll make the connection to your Horizon View Connection Server by running

$hvServer = Connect-HVServer -server 

When prompted for username/password be sure to use your domain_name\username or username@domainname”

We can now query the pools by running “$pools = get-hvpool”. This will return all pools. I would suggest filtering the data from this variable for later use. For example, type “$pools.Base.Name” to return the pool’s Identifiers; or type “$pools.Type” to filter between manual and automated.

In my instance, I needed to run these commands on all manual pools, so very little filtering was required, which I accomplished using an if statement.

Let’s get to the commands.

Do not allow a user to choose display protocol

foreach ($pool in $pools){
    if ($pool.Type -eq "MANUAL){
        set-hvpool -pool $pool -key 'desktopSettings.displayProtocolSettings.allowUsersToChooseProtocol' -value $false } }

Set the maximum number of monitors to 2

foreach ($pool in $pools){
    if ($pool.Type -eq "MANUAL){
        set-hvpool -pool $pool -key 'desktopSettings.displayProtocolSettings.pcoipDisplaySettings.maxNumberOfMonitors' -value 2 } }

Allow users to reset their desktop

foreach ($pool in $pools){
    if ($pool.Type -eq "MANUAL){
        set-hvpool -pool $pool -key 'desktopSettings.logoffSettings.allowUsersToResetMachines' -value $true } }

Disable HTML Access

foreach ($pool in $pools){
    if ($pool.Type -eq "MANUAL){
        set-hvpool -pool $pool -key 'desktopSettings.displayProtocolSettings.enableHTMLAccess' -value $false } }

And the trickiest one for last. View Storage Accelerator blackout times. All of the pools in my environment have View Storage Accelerator enabled, but with no blackout times defined. This is not ideal, for example, if a user happens to shut down their VM in the middle of the day, View sometimes sees that as an opportunity to recalculate the disk digest, which means the user is unable to get back into their VM for several minutes. For some reason, I have been unable to get a custom “VMware.hv.desktopblackouttime” array to be accepted by the set-hvpool command. What I’ve had to do is manually configure a sample pool with the correct blackout times in the Horizon Admin console, and then export those to a variable from PowerCLIl. I am then able to use the set-hvpool command successfully.

Set Blackout Times

$referencepool = get-hvpool -poolname 'ReferencePool'
$blktimes = $referencepool.ManualDesktopData.ViewStorageAcceleratorSettings.BlackoutTimes

foreach ($pool in $pools){
    if ($pool.Type -eq "MANUAL){
        set-hvpool -pool $pool -key 'manualDesktopData.viewStorageAcceleratorSettings.blackoutTimes' -value $blktimes} }

You’ll notice the “keys” are typed in camelCase. I had a lot of trouble figuring this out at first – it is case sensitive but I couldn’t find them typed like this anywhere in the API reference guide. It doesn’t seem to be a perfect rule, for example, HTML is all caps in the desktop settings.displayProtocolSettings.enable HTML access key. I’d appreciate any feedback if you know a place where these are listed, or how to find them without guessing.

You might be interested in …

Install App Volumes Manager 2.15

AppVolumes, VMware

In this post, I will show you the installation steps of the App Volumes Manager. The installation will be straight forward. These installation steps can be used when installing your first App Volumes Manager but also when you install a second App Volumes Manager in your deployment. At the database connection step, I will explain […]

Read More

Unified Access Gateway with Microsoft Azure AD Integration using SAML

Many customers are moving towards extending their Datacenter workloads to the clouds, and Microsoft Azure is one of the partners that the VMware EUC team works very closely with. VMWare Unified Access Gateway, what we called “UAG,” is available in the Azure AD app gallery directly, reducing and simplifying the efforts of integration and configurations.  […]

Read More

Workspace ONE Access Multisite Tasks – One Pager

vIDM, VMware, Workspace ONE Access

For the past few weeks, I have been working with my project team and my customer to help them stand up VMware Access on a secondary site. With the help of Haseeb Waseem, I have created a single spreadsheet which includes all the major steps needed to create a secondary site. Hope this is helpful […]

Read More

Leave a Reply

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