Changing your VMware license server

Hi everybody, I’m back!

Before you ask, I’ve had a great holiday, thank you. Now let’s continue having fun with Powershell and the VI Toolkit!

I’ve showed you a trick earlier that allows you to find your Virtual Center Server Settings. The License Server settings for instance. But changing these settings can prove to be quite a challenge. Let’s take a look:

$SI = Get-View ServiceInstance
$LicMan = Get-View $SI.Content.LicenseManager

This is the way we connected to the License Manager. Get-Member shows us that the $LicMan variable has a method called ConfigureLicenseSource. This method required two parameters: first a reference to the ESX server and second an object with the new license server settings.

The “managed object reference” to the ESX server took some time to figure out, but it’s actually quite easy:

$ESXServerName = “ESXSERVER01”
$VMHost = Get-VMHost $ESXServerName
$hostref = ($VMHost | Get-View).MoRef

By now, you should know how to use Get-View a bit. The resulting object has a MoRef property which can be used in the ConfigureLicenseSource method.

The object containing the new license settings was also a bit of a puzzle. The method shows it wants an object of type “LicenseSource”. But after consulting the VMware Infrastructure API Reference, I found this type of object has no properties! Then how to set the license server name and port?
More searching yielded a different type of object “LicenseServerSource”. This object type has a property called LicenseServer, which accepts a string as input. This object extends the LicenseSource object (according to the API Reference) and it turns out you can use it in the method:

$LicServer = “27000@LicenseServer.domain.local”
$licsrc = New-Object VMware.Vim.LicenseServerSource
$licsrc.LicenseServer = $LicServer

Now we have all the info we need, and we can execute the method:



6 thoughts on “Changing your VMware license server

  1. […] like how his article on configuring the license server doesn’t assume much and walks you through the […]

  2. @Ryan Simply create a loop around the script that handles all VMHosts. Like so:
    Connect-VIServer “MYVCSERVER”
    ForEach ($VMHost in Get-VMHost)
    CODE TO CHANGE LICENSE SERVER (copy/paste from quotes and remove the line that starts with $VMHost= )
    Disconnect-VIServer -Confirm:$False
    Is that what you were looking for?

Leave a Reply