VMware Horizon – Configure Horizon License with PowerCLI

Release date: January 10th 2023

Welcome to my VMware Horizon series. I recently experienced a complete hardware crash in my old lab, and had to do a complete rebuild. Although this was sad, it gave me the opportunity to do it by scripting this time. As part of the exercise, I wanted to do all the installation/configuration from the management server using PowerShell and PowerCLI. In this little session I will describe how to add a Horizon license key to a Connection Server using PowerCli.


  • PowerShell Administrative access to the Connection-server

The first thing I had to do, was to create the credentials which is used in the script:

  • 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).


# --- Initialize PowerCLI Modules --- 
Import-Module 'VMware.Hv.Helper'

$hvServer = "fqdn cs server"
$credential = Import-CliXml -Path "<path>\hz_admin_${env:USERNAME}_${env:COMPUTERNAME}.xml"
$hvserver1=connect-hvserver $hvServer -cred $credential
$licenseKey = "xxxxx-xxxxx-xxxxx-xxxxx-xxxxx"

# --- Add License Key --- 
$ViewAPI = $global:DefaultHVServers.ExtensionData
set-HVlicense $licenseKey

VMware Official Documentation:

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: