When adding a license key into vCenter Server using the vSphere UI, users have the ability to provide a custom label that is then associated with that specific license key.
This is certainly more useful than the system default label which uses "License N", where N is an incrementing number.
While the majority of license management can be fully automated using the vCenter Server LicenseManager API, adding a license key with a custom label is unfourntately an operation that is currently not possible with the public API.
With that said, there is a way in which you can still automate this operation 🙂
Not to bore you with all the details, but there is a private API for managing licenses with custom labels which is part of the vSphere Lookup Service (LS) API within vCenter Server. While directly accessing the API through a typical vSphere SDK is not possible, we do have a trick up our sleeve by using the LS Managed Object Browser (MOB) interface, which is similiar to that of the vSphere MOB.
The LS MOB is available under /ls/mob and is also an authenticated endpoint, meaning you must have valid vCenter Server credentials along with the appropriate permissions to perform the given operation. Leveraging the automation I wrote back in 2016 for automating against the vSphere MOB, we can craft a simliar PowerShell script or using any other language which can invoke a web request to automate this specific operation.
I have created the following PowerShell example script called add-vcenter-license-with-label-via-mob.ps1 which you will need to download locally to your desktop and then update the following variables to match those within your enviornment:
- $vc_server - FQDN/IP Address of your vCenter Server
- $vc_username - vCenter Server user to perform the license addition
- $vc_password - vCenter Server password to user account
- $license_name - Custom label for the license key to add to vCenter Server
- $license_key - License key to add to vCenter Server
Once you have saved your changes, you can then run the script using the following command:
./add-vcenter-license-with-label-via-mob.ps1
If the operation was successful, you should see simliar output as shown in the screenshot above and you can now refresh the vSphere UI to see your newly license key added with a custom label.
Thanks for the comment!