VMware Horizon – Upgrade Horizon Enrollment Server to v. 2212

Release date: January 23rd 2023

Welcome to my VMware Horizon series. In this session I will describe how I upgraded my VMware Horizon Enrollment Server to v. 2212. The upgrade of the VMware Horizon Enrollment Server is quite similar to upgrading the Connection Servers. 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. According to VMware’s official documentation, this should be done as step 7 in the supported update sequence.

As with the Connection Server upgrade, I start out by downloading the installation media from VMware Customer Connect


  • PowerShell Administrative access to the Connection-server

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 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!)

The script will perform the following:

  • Connect to vCenter
  • Shut down the Enrollment Server
  • Take Snapshot
  • Power Up the Enrollment Server
  • Create a temp folder on c-drive of the Enrollment server and copy the latest Connectionserver*.exe from a networkshare
  • Upgrade the Enrollment Server
  • Restart the VM
  • Wait for Enrollment Server service to start
  • Delete temp-folder on c-drive
  • Remove Snapshot


# --- 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

# --- Shut Down VM ---

$EnrollSrv = "enrollmentserver fqdn (=vm name)"

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

# --- Take Snapshot ---

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

# --- Power On VM ---

Start-VM -VM $EnrollSrv
Start-Sleep 180 # SLOW LAB :)

# --- Configure PSSession ---

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

# --- Define, Copy and Run Installers ---

Invoke-Command -Session $session -ScriptBlock {
    # Variables
    $InstallDir = "C:\Install\"
    $ExeName = "VMware-Horizon-Connection-Server*"
    $Exe = "\\<Network-Path>\$ExeName"
    $Vendor = "VMware"
    $Product = "Horizon Enrollment Server"
    # Creating temp-folder, copy installer
    New-Item -Path $installDir -type directory -Force
    Copy-Item -Path $Exe -Destination $InstallDir -Force
    # VMware Horizon Enrollment Server MSI Switches
    $EnrollSrvArgs = @(
        "VDM_SERVER_INSTANCE_TYPE=5" # Enrollment Server

    # Upgrade Enrollment Server

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

Remove-PSSession $session
Get-VM $EnrollSrv | Restart-VMGuest

Start-Sleep 180

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

Invoke-Command -Session $session -ScriptBlock {

# Waiting for VMware Horizon View Enrollment Server Service to start"

    $SvcName = 'wsenroll'
    $SvcDisplayName = "VMware Horizon View Enrollment Server Service"
    $Svc = Get-Service -Name $SvcName
    Write-Host "Waiting for VMware Horizon View Enrollment 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

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

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

This concludes my session about upgrading the Enrollment server to v. 2212. I can now proceed with upgrading the Horizon Recording Server, posted here: Horizon Recording Server, covered here: VMware Horizon – Upgrade Horizon Desktop Recording Server to v. 1.6.3

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: