VMware Horizon – Upgrade Client repository with Horizon 2212 Clients

Release date: January 20th 2023

Welcome to my VMware Horizon series. Upgrading the Horizon Client is the first step in upgrading a Horizon environment, as shown below. As the Horizon Client is distributed in all kinds of different ways to users, GPO, application deployments, scripts, I won’t go into this now.

In a production environment, it is advisable to have the users upgrade their clients first. A smart approach to doing this, is to alert the users of this by using Client Restrictions. The newer Horizon Client editions are backward compatible and it is preferable to have as many as possible upgraded before upgrading the rest of the Horizon components. This can bee done by editing the Client Restrictions under Global Settings in Horizon Administrator GUI.

In my setup, I will block clients older than 8.5.0 and send warning to users on this version.

In my lab, I use the Horizon Portal to distribute clients. Previously, I have created this distribution point manually. In this session however, I will show how to do this using PowerShell.

Prequisites:

  • PowerShell Administrative access to the Connection-server
  • Pre-downloaded client binaires to network share
  • Pre-configured portal-links-html-access.properties file

I first create the following credentials to be used in the script:

  • vCenter admin-user:
New-VICredentialStoreItem -User <user> -Password <user> -Host <server> -File C:\<your location.xml>
  • Horizon admin-user:
$credential = Get-Credential
$credential | Export-CliXml -Path '<path>\hz_admin.xml'

Now that I have the credentials ready, I am good to go. (PS: I know I’m no programmer and a lot of this script have the potential for improvement, but, it gets the job done, and that’s good enough for me. If You have input to making this script even better, please leave a comment below, it will be greatly appreciated!)

Upgr_cli_rep.ps1

# --- Initialize PowerCLI Modules --- 
   
Import-Module VMware.VimAutomation.Core
Import-Module VMware.VimAutomation.Common
Set-PowerCLIConfiguration -Scope User -ParticipateInCeip $false -Confirm:$false
Set-PowerCLIConfiguration -InvalidCertificateAction ignore -Confirm:$false
Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Confirm:$false

# --- Connect to vCenter with Get-VICredentialStoreItem ---

$viserver = "vCenter fqdn"
$viuser = Get-VICredentialStoreItem -File "<path to vCenter Credentials>.xml" -host $viserver
Connect-viserver -Server $viserver -User $viuser.user -Password $viuser.password

$cs = "hz-cs-01.ad.admin.frelab.net"

# --- Configure PSSession ---

$credential = Import-CliXml -Path "<path to horizon admin>\hz_admin_${env:USERNAME}_${env:COMPUTERNAME}.xml"
$session = New-PSSession -ComputerName $cs -Credential $credential -Authentication CredSSP

# --- Define variables, create folders and copy files ---

Invoke-Command -Session $session -ScriptBlock {
    
# Variables
    $ClientDir = "C:\Program Files\VMware\VMware View\Server\broker\webapps\downloads"
    $ClientSource = "<Network Path to Horizon Clients>\Latest\*"
    $PortalLnksDest = "C:\ProgramData\VMware\VDM\portal\"
    $PortalLnksOrg = "C:\ProgramData\VMware\VDM\portal\portal-links-html-access.properties"
    $PortalLnksBackup = "C:\ProgramData\VMware\VDM\portal\portal-links-html-access_properties.bak"
    $PortalLnksSource = "\\BCKUP-01\Install\VMware\Horizon\Clients\portal-links-html-access.properties"
           
# Creating downloads-folder, copy client installers
    New-Item -Path $ClientDir -type directory -Force
    Copy-Item -Path $ClientSource -Destination $ClientDir -Force

# Backup and replace portal-links-html-access.properties
    Copy-Item $PortalLnksOrg $PortalLnksBackup -Force
    Copy-Item $PortalLnksSource $PortalLnksDest -Force

}

Remove-PSSession $session

# --- Restart Connection Server ---
Write-Host "Restarting Connection Server" -ForegroundColor Green

Get-VM $cs | Restart-VMGuest

Start-Sleep 180

$session = New-PSSession -ComputerName $cs -Credential $credential -Authentication CredSSP

# --- Check Service-status after Connection Server reboot ---

Invoke-Command -Session $session -ScriptBlock {
    
    $SvcName = 'wsbroker'
    $SvcDisplayName = "VMware Horizon View Connection Server Service"
    $Svc = Get-Service -Name $SvcName
    
    # Waiting for VMware Horizon View Connection Server Service to start"
    Write-Host "Waiting for VMware Horizon View Connection Server Service to start" -ForegroundColor Green
    if ($Svc.Status -eq 'Running')
        {
        Write-Host "$SvcDisplayName is now Running" -ForegroundColor Green
        }

    if ($Svc.Status -ne 'Running')
        {
        Write-Host "Waiting for $SvcDisplayName to start" -ForegroundColor Green
        $Svc.WaitForStatus("Running")
        Write-Host "$SvcDisplayName is now running" -ForegroundColor Green
        }
}

# --- Disconnect from vCenter ---
write-host "Disconnecting from vCenter" -ForegroundColor Green
Disconnect-VIServer -Server $viserver -Confirm:$false

In the VMware Horizon portal, the users can now click “Install VMware Horizon Client”, which will install the Horizon Client directly from the Connection Server.

VMware Horizon – Upgrades

VMware Horizon planning, deployment etc.

Official VMware Horizon 8 Documentation

Disclaimer: Every tips/tricks/posting I have published here, is tried and tested in different it-solutions. It is not guaranteed to work everywhere, but is meant as a tip for other users out there. Remember, Google is your friend and don’t be afraid to steal with pride! Feel free to comment below as needed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: