VMware Horizon – Upgrading Horizon Connection Server to v.2303

Release date: April 5th 2023

Welcome to my VMware Horizon series.  In this session I will describe how I upgraded my VMware Horizon Connection Servers to v. 2303. Previously I have shown how to do this manually, in this session I will show how to do this with PowerShell and PowerCLI, remotely from a management server. Before I start, I review VMware’s documentation describing this topic:

According to VMware’s official documentation, this should be done as step 7 in the supported update sequence.

 I start out by downloading the installation media from VMware Customer Connect

First, I verify the installed version:

Before I start I make myself a little workflow as show below.


  • PowerShell Administrative access to the Connection-server

I first created 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 had the credentials created, I was 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 very much appreciated!)


# --- 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 = "cs fqdn"

# Check for Snapshots and remove any
Get-Snapshot $cs | Remove-Snapshot -confirm:$false

# --- Shut Down VM ---

   $vm = Get-VM -Name $cs -ErrorAction Stop
   'poweredon' {
  Shutdown-VMGuest -VM $vm -Confirm:$false
   while($vm.PowerState -eq 'PoweredOn'){
  sleep 5
   $vm = Get-VM -Name $cs
   Default {
   Write-Host "VM '$($cs)' is not powered on!"
   Write-Host "$($cs) has shutdown. It should be ready for configuration."
   Write-Host "VM '$($cs)' not found!"

# --- Take Snapshot ---

$SnapshotName = "Pre-Upgrade"
Get-VM $cs | New-Snapshot -Name $SnapshotName

# --- Power On VM ---

Start-VM -VM $cs
# Wait 5 minutes - SLOW LAB :)
Start-Sleep 300

# --- 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, Copy and Run Installer ---

Invoke-Command -Session $session -ScriptBlock {

# Variables
    $InstallDir = "C:Install"
    $ExeName = "VMware-Horizon-Connection-Server*"
    $ExeFile = "<Network-Path>Latest$ExeName"
    $Vendor = "VMware"
    $Product = "Horizon Connection Server"

# Creating temp-folder, copy installer
    New-Item -Path $InstallDir -type directory -Force
    Copy-Item -Path $ExeFile -Destination $InstallDir -Force

# VMware Connection Server MSI Switches
    $MsiArgs = @(
        "VDM_SERVER_INSTANCE_TYPE=1" # Connection Server

# Upgrade Connection Server
    Write-Host "Upgrading $Vendor $Product" -ForegroundColor Green
    $Exe = (Get-ChildItem -Path $InstallDir | Where-Object {$_.name -like $ExeName}).Fullname
    $Install = (Start-Process -Filepath $Exe -Wait -ArgumentList "/s /v""$MsiArgs" -PassThru)
    if ($Install.ExitCode -ne '0')
        Write-Host "The upgrade failed, revert to snapshot, remediate error and try again" -ForegroundColor Red

# Copy locked.properties to .sslgatewayconf folder - Just in case....    
    $LockedPropertiesFile = "<Network Path>locked.properties"
    $SslGatewayDir = "C:Program FilesVMwareVMware ViewServersslgatewayconf"
    Copy-Item -Path $LockedPropertiesFile -Destination $SslGatewayDir -Force
    Remove-Item –path $installDir –Recurse -Force
Remove-PSSession $session

Get-VM $cs | Restart-VMGuest

# Wait 3 minutes - SLOW LAB :)
Start-Sleep 180

# --- Remove Temp folder and install media ---
Write-Verbose "Remove temp folder and snapshot" -Verbose
$session = New-PSSession -ComputerName $cs -Credential $credential -Authentication CredSSP

Invoke-Command -Session $session -ScriptBlock {

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

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

# Tidying up
    $installDir = "C:Install"
    Remove-Item –path $installDir –Recurse -Force
Remove-PSSession $session

# Remove Snapshot
Read-Host "Press Any Key to remove Snapshot"
Get-VM $cs | Get-snapshot -Name $SnapshotName | Remove-Snapshot  -Confirm:$false

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

Once the script finishes, I can now verify the new version.

With the Connection Server upgraded, I can now proceed with upgrading the Horizon Enrollment Server, covered here: VMware Horizon – Upgrade Horizon Enrollment Server to v.2303

VMware Official Documentation:

VMware Horizon – Upgrades

VMware Horizon planning, deployment etc.

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: