I have showed you before how to access the License Manager with the Powershell VMware VI Toolkit. But the properties of the License Manager appear to only reflect the Virtual Center License Information. So how do we get information about licensing for each individual ESX Server?
We need to take a look at the methods of the License Manager.
First, we connect to the License Manager:
$SI = Get-View ServiceInstance
$LM = Get-View $SI.Content.LicenseManager
Examine the methods of the License Manager:
Lets see how the QueryLicenseUsage method works:
It requires one parameter host of type ManagedObjectReference. So we need a reference to a VMHost:
$VMHostView = Get-VMHost “NAME” | Get-View
$VMHostRef = $VMHostView.MoRef
Now we can call the method:
$LicUse = $LM.QueryLicenseUsage($VMHostRef)
Useful information includes:
$LicUse.Source.LicenseServer # Contains the license server name and port
$LicUse.ReservationInfo # Contains license information for each feature available
To find more information about each feature, take a look at the FeatureInfo property of the License Manager:
$LM.FeatureInfo
Now, you can take the info you need and use it in your scripts.
Enjoy!
Hugo
No related posts.





Forbes Guthrie
January 6th, 2009
Hi Hugo,
I’ve used the “$LicUse.sourceAvailable” value as it returns a simple boolean value, which I can use in your “Custom Fields” script. However I’m not sure if saying that the host can see the license server is the same as saying it is currently licensed.
Ideally I’d like to figure out how to suck the value of “State” for the “esxFull” Key, which comes from “$LicUse.ReservationInfo”.
This would output the following possible values: http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.LicenseManager.ReservationInfo.State.html
However I’m not sure how to plug that into your script. I’ll let you know if I figure it out. Many thanks, Forbes.
admin
January 7th, 2009
Forbes,
Try this:
$ForbesValue = ( $LicUse.ReservationInfo | Where {$_.Key -eq “esxFull”} ).State
Hugo
Forbes Guthrie
January 7th, 2009
I like the variable moniker! Very catchy :)
Thanks, Forbes.