The datacenter hummed like a distant galaxy. Rows of racks stood sentinel beneath cool, fluorescent skies; each server a planet orbiting the control room where Mira kept watch. She was the cluster’s steward, a sysadmin who found truths in logs and poetry in prompts. Today, the problem had a name: licensing.
At 07:12 the monitoring alerts bloomed across her console — several hosts reporting expired vCenter licenses. Production would be throttled if those VMs lost privileges. Mira sipped cold coffee and opened a secure shell to the management appliance. The GUI was slow and sentimental; she preferred crisp, decisive commands.
She typed:
# Connect to vCenter Appliance shell
ssh root@vcenter.example.local
# List current vCenter licenses
vim-cmd vimsvc/license --list
The output scrolled like constellations: keys, IDs, counts. One key glared in red — expired. Mira swiped it away with another command she’d crafted months ago and kept safe in an encrypted snippet on her hardware token.
First she added the new license:
vim-cmd vimsvc/license --add XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
The system acknowledged with an unobtrusive “License added.” Next she assigned it to the inventory:
vim-cmd vimsvc/license --assign vmware vCenterServerLicenseKey
A pause — then confirmation. Hosts began to sigh relief, and resource limits lifted like a tide.
Still, Mira didn’t trust silence. She verified:
vim-cmd vimsvc/license --list
esxcli software vib list | grep -i license
The entries now reflected the new key and valid capacity. She pushed an automated note to the ops channel: license updated, no action needed. The monitoring dashboard stopped flagging; green returned.
Later, in a quieter hour, Mira wrote a small script to prevent future surprises: a nightly check that would alert her a week before expiration and hold the new key in a secure vault until needed. She documented the steps in the runbook with crisp comments and a timestamp.
That evening, as the datacenter lights dimmed, Mira walked past the racks. The servers thrummed in steady accord. In the cool glow of the control room, she felt the same satisfaction as when a watchmaker finishes a complicated repair — the whole system, licensed and aligned, ready for whatever tomorrow would run. vcenter license key command line
To manage vCenter license keys via the command line, you primarily use (VMware's PowerShell module) or
. Standard SSH commands within the vCenter Server Appliance (vCSA) shell are generally not used for license assignment, as licensing is an application-level service. 1. Using PowerCLI (Recommended)
PowerCLI is the standard command-line interface for managing vSphere. You can add and assign licenses using the LicenseManager LicenseAssignmentManager To Add a License to the Inventory: powershell # Connect to your vCenter Connect-VIServer -Server "vcenter_fqdn" "administrator@vsphere.local" "your_password" # Get the License Manager view
$licenseMgr = Get-View (Get-View ServiceInstance).Content.LicenseManager # Add the license key $licenseMgr.AddLicense( "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" Use code with caution. Copied to clipboard TheCloudXpert To Assign the License to the vCenter Server: powershell
$si = Get-View ServiceInstance $assignmentMgr = Get-View $licenseMgr.LicenseAssignmentManager $vCenterUuid = $si.Content.About.InstanceUuid # Assign the key to the vCenter instance $assignmentMgr.UpdateAssignedLicense($vCenterUuid, "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" "vCenter License Name" Use code with caution. Copied to clipboard LucD Notes To Check Existing Licenses on Hosts: powershell Get-VMHost | Select-Object Name, LicenseKey Use code with caution. Copied to clipboard Broadcom Community 2. Using Ansible If you use automation tools, the community.vmware.vcenter_license module allows you to manage keys declaratively. Example Playbook Task: : Add a new vCenter license community.vmware.vcenter_license " vcenter_hostname " " vcenter_username " " vcenter_password " "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" Use code with caution. Copied to clipboard Ansible Documentation 3. Local Shell (ESXi Only)
While you cannot license vCenter itself directly through its own local SSH shell easily, you can view or set an ESXi host's license key via its local shell using Show License: vim-cmd vimsvc/license --show Set License: vim-cmd vimsvc/license --set XXXXX-XXXXX-XXXXX-XXXXX-XXXXX Broadcom Community PowerCLI script that connects, adds, and assigns the license in one go?
How to display license key | VMware vSphere - Broadcom Community
vim-cmd vimsvc/license --show This will list the key under the field "serial:" if one exists. Broadcom Community Manage VMware vCenter license keys - Ansible documentation
To manage VMware vCenter license keys through the command line, you primarily use VMware PowerCLI, which is a powerful PowerShell-based interface. While you can also use Ansible or the ESXi shell for host-specific tasks, PowerCLI is the standard for managing vCenter-level assets. 1. Update vCenter License Key (PowerCLI)
To update or assign a license key to your vCenter Server instance, you must interact with the LicenseManager through the vCenter extension data. powershell The datacenter hummed like a distant galaxy
# 1. Connect to your vCenter Server $vCenter = Connect-VIServer -Server "vcenter.domain.com" -User "administrator@vsphere.local" -Password "YourPassword" # 2. Get the License Manager view $LM = Get-View ($vCenter.ExtensionData.Content.LicenseManager) # 3. Add the license key to the vCenter inventory $licenseKey = "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" $LM.AddLicense($licenseKey, $null) # 4. Assign the license to the vCenter instance $LAM = Get-View ($LM.LicenseAssignmentManager) $LAM.UpdateAssignedLicense($vCenter.InstanceUuid, $licenseKey, $null) Use code with caution. Copied to clipboard
Verification: You can check the current vCenter license by running (Get-View $vCenter.ExtensionData.Content.About).InstanceUuid to confirm it matches the assigned ID. 2. Set License Key for ESXi Hosts (PowerCLI)
If you are managing licenses for individual ESXi hosts via vCenter, use the Set-VMHost cmdlet. For a Single Host: powershell
Set-VMHost -VMHost "esxi-01.domain.com" -LicenseKey "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" Use code with caution. Copied to clipboard For all Hosts in a Cluster: powershell
Get-Cluster "ClusterName" | Get-VMHost | Set-VMHost -LicenseKey "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" Use code with caution. Copied to clipboard 3. Managing Licenses via Ansible
For automation, the community.vmware.vcenter_license module allows you to add or remove keys.
- name: Add a new vCenter license key community.vmware.vcenter_license: hostname: " vcenter_hostname " username: " vcenter_username " password: " vcenter_password " license: "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" state: present delegate_to: localhost Use code with caution. Copied to clipboard 4. ESXi Shell (Standalone Hosts Only)
For a standalone ESXi host not managed by vCenter, you can use the vim-cmd utility directly via SSH.
Command: vim-cmd vimsvc/license --set=XXXXX-XXXXX-XXXXX-XXXXX-XXXXX Summary of Common Commands Command/Snippet Add Key to Inventory $LM.AddLicense("KEY", $null) Assign to vCenter $LAM.UpdateAssignedLicense($UUID, "KEY", $null) Assign to ESXi Set-VMHost -LicenseKey "KEY" Reset to Eval Mode Set-VMHost -LicenseKey "00000-00000-00000-00000-00000" Assign to Standalone ESXi vim-cmd vimsvc/license --set=KEY Set the License Key for a Host on vCenter Server
Managing vCenter license keys via the command line is a critical skill for administrators looking to automate deployments or maintain environments without relying on the vSphere Client. While VMware (now Broadcom) primarily emphasizes the GUI for licensing, you can perform these tasks efficiently using VMware PowerCLI or by interacting with the vCenter Server Appliance (VCSA) API. Managing Licenses with PowerCLI The output scrolled like constellations: keys, IDs, counts
PowerCLI is the most powerful tool for CLI-based license management. It allows you to add keys to the vCenter inventory and then assign them to specific assets like the vCenter Server itself or ESXi hosts. 1. Adding a License Key to the Inventory
To add a new key to your vCenter Server’s central repository, use the following snippet to access the LicenseManager: powershell
# Connect to your vCenter Connect-VIServer -Server "://example.com" -User "Administrator@vsphere.local" -Password "YourPassword" # Access the License Manager $vCenter = Get-VIServer -Server "://example.com" $licenseManager = Get-View $vCenter.ExtensionData.Content.LicenseManager # Add the new license key $licenseManager.AddLicense("XXXXX-XXXXX-XXXXX-XXXXX-XXXXX", "Optional Label") Use code with caution.
Note: Using AddLicense only puts the key in the "Available" pool. You must still assign it to an asset to activate it. 2. Assigning the Key to vCenter Server
Once the key is in the inventory, you can assign it to the vCenter instance itself using the LicenseAssignmentManager. How to Manage vCenter and ESXi License Keys via PowerCLI
Only works if the license is not assigned to any asset.
vcenter.license.remove --key <LICENSE_KEY>
Managing licenses through the vSphere Client (GUI) is standard, but automating license injection or managing hosts without a GUI requires the Command Line Interface (CLI). This guide focuses on the vSphere CLI (vCLI) and PowerCLI, the two primary methods for this task.
| Issue | Solution |
|-------|----------|
| “License not found” | Run vcenter.license.list first to confirm key format. |
| “Cannot remove – assigned” | Unassign from all assets using vcenter.license.unassign then retry. |
| “Insufficient capacity” | Your license doesn’t have enough CPU cores or VMs for the assigned assets. Upgrade or reduce assignments. |
| “Evaluation period expired” | You never assigned a real license. Add and assign a valid key immediately. |
licmgr --server <ESXi_IP> --username root info
To check or manage license keys, you would typically use the vicli command with specific options. Here is an example to get you started: