/usr/lib/vmware-vcenter-license-service/scripts/license.py list --show-id Then remove:
Get-License -Key "XXXXX" | Select-Object Total, Used You must first unassign from all hosts and vCenter itself. Using PowerCLI:
$licenses = Get-License $today = Get-Date $warningDays = 30 foreach ($lic in $licenses) if ($lic.ExpirationDate -and $lic.ExpirationDate -ne [DateTime]::MaxValue) $daysLeft = ($lic.ExpirationDate - $today).Days if ($daysLeft -le $warningDays -and $daysLeft -ge 0) Write-Warning "License $($lic.Key) expires in $daysLeft days on $($lic.ExpirationDate)" elseif ($daysLeft -lt 0) Write-Error "License $($lic.Key) expired on $($lic.ExpirationDate)"
vim-cmd vimsvc/license --list vim-cmd vimsvc/license --remove <moref> This reverts the host to evaluation mode (60 days). C. The Deprecated Windows vCenter Tool: licensesvc If you are still on a Windows-based vCenter (6.x or earlier), you can use: vcenter license key command line
/usr/lib/vmware-vcenter-license-service/scripts/license.py list | grep -B2 -A2 "YourPartialKey" Or use PowerCLI to find duplicates. Means the license doesn't have enough free CPUs. Check usage:
vim-cmd vimsvc/license --assign 12345-67890-abcde-fghij-klmno domain-c1234 /usr/lib/vmware-vcenter-license-service/scripts/license.py usage This shows how many CPU licenses are used by which hosts. B. Legacy ESXi Commands (via vCenter Shell) Even from vCenter's bash, you can execute commands that target ESXi hosts through the vCenter's proxy. However, direct ESXi licensing commands are now discouraged in favor of the license service. View Host's Current License Connect to the host's shell or use vim-cmd from vCenter:
/usr/lib/vmware-vcenter-license-service/scripts/license.py remove --id <license-id> This is done by editing the host's configuration via the vim-cmd tool (which communicates with vCenter's managed object broker). /usr/lib/vmware-vcenter-license-service/scripts/license
$oldKey = "11111-22222-33333-44444-55555" $newKey = "99999-88888-77777-66666-55555" Add new license first New-License -LicenseKey $newKey -Name "Replacement License" Find all hosts using old license $affectedHosts = Get-VMHost | Where-Object $_.LicenseKey -eq $oldKey Reassign foreach ($hostObj in $affectedHosts) Set-VMHost -VMHost $hostObj -LicenseKey $newKey Remove old license if no longer used $oldLicense = Get-License -Key $oldKey if ($oldLicense.Used -eq 0) Remove-License -License $oldLicense -Confirm:$false
Example:
tail -f /var/log/vmware/vcenter-license-service/license-service.log Check if already added: The Deprecated Windows vCenter Tool: licensesvc If you
License Key: 00000-00000-00000-00000-00000 Name: vSphere 7 Enterprise Plus Total: 2 CPUs Used: 1 CPUs Expiration: Never Status: OK License Key: 11111-11111-11111-11111-11111 Name: vCenter Server 7 Total: 1 Instance Used: 1 Instance Expiration: 2025-12-31 Status: OK /usr/lib/vmware-vcenter-license-service/scripts/license.py add --key XXXXX-XXXXX-XXXXX-XXXXX-XXXXX To add with a custom label:
In large-scale virtualized environments, the vSphere Web Client is the standard graphical interface for managing licenses. However, when you need to automate, troubleshoot, or perform bulk operations, the command line becomes indispensable. For vCenter Server (both Windows-based and the vCenter Server Appliance - VCSA), several command-line interfaces allow you to view, add, assign, and remove license keys.
systemctl status vcenter-license-service systemctl restart vcenter-license-service
Issue: "Unable to connect to license service" On VCSA:
vim-cmd vmsvc/getallvms # Not for hosts # Better: use PowerCLI, or from vCenter shell: Alternatively, use vim-cmd hostsvc/hostsummary but that requires the host to be added to vCenter.