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:

$LM | Get-Member -MemberType method
methods

Lets see how the QueryLicenseUsage method works:

$LM.QueryLicenseUsage
methoddef

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
reservationinfo

To find more information about each feature, take a look at the FeatureInfo property of the License Manager:

$LM.FeatureInfo

featureinfo

Now, you can take the info you need and use it in your scripts.

Enjoy!

Hugo

»crosslinked«

Related posts:

  1. Calculate vSphere 5 Licenses with Powershell (UPDATED)
  2. Remove vmware memory limits with Powershell

  4 Responses to “Getting detailed VMware license information with Powershell”

  1. 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.

  2. Forbes,
    Try this:
    $ForbesValue = ( $LicUse.ReservationInfo | Where {$_.Key -eq “esxFull”} ).State
    Hugo

  3. I like the variable moniker! Very catchy :)

    Thanks, Forbes.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

   
© 2012 PeetersOnline Suffusion theme by Sayontan Sinha