WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud
  • Tanzu
    • Application Modernization
    • Tanzu services
    • Tanzu Community Edition
    • Tanzu Kubernetes Grid
    • vSphere with Tanzu
  • Home Lab
  • Nested Virtualization
  • Apple
You are here: Home / Automation / How to automate adding a license into vCenter Server with custom label? 

How to automate adding a license into vCenter Server with custom label? 

02.06.2023 by William Lam // Leave a Comment

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.

More from my site

  • PowerShell community module for Application Transformer for VMware Tanzu
  • ESXi-Arm Licensing Options
  • Programmatically interact with the VMware Product Lifecycle Matrix
  • Workspace One Access (vIDM) Powershell Module to automate creating 3rd Party Identity Provider
  • PowerShell for PhotonOS on Raspberry Pi 3

Categories // Automation, vSphere 7.0, vSphere 8.0 Tags // license, powershell

Thanks for the comment! Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Infrastructure Business Group (CIBG) at VMware. He focuses on Cloud Native technologies, Automation, Integration and Operation for the VMware Cloud based Software Defined Datacenters (SDDC)

Connect

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Recent

  • How to enable passthrough for USB Network Adapters claimed by ESXi CDCE Driver? 03/30/2023
  • Self-Contained & Automated VMware Cloud Foundation (VCF) deployment using new VLC Holodeck Toolkit 03/29/2023
  • ESXi configstorecli enhancement in vSphere 8.0 Update 1 03/28/2023
  • ESXi on Intel NUC 13 Pro (Arena Canyon) 03/27/2023
  • Quick Tip - Enabling ESXi Coredumps to be stored on USB 03/26/2023

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2023

 

Loading Comments...