VMware PowerCLI

The Best User Interface for your VMware Datacenter!

PowerCLI for Licenses

It would be great to have Cmdlets for adding/removing/assigning/getting licenses via PowerCLI for all relevant products. i.e. ESXi license, vCenter license, vSAN License etc.

 

This would help improve the ability to add/assign licenses quickly but also to help with reporting

  • David Menzies
  • Sep 18 2017
  • Planned
  • Attach files
  • Marcel Swartjes commented
    8 Apr 03:16pm

    It would be great if we can use this functionality for retrieving license/usage information we can use in license compliancy reports instead of making screenshots. Including VMware products like Horizon View, NSX, VROPS, Loginsight, VRNI, VRA, Appvolumes

  • Brian Parks commented
    6 Aug, 2018 03:08pm

    I'm using this code (modified from something I found on Internet). You can add multiple license keys, and the vCenter license key will be assigned.  I've not found anything to determine the currently assigned license key for vCenter, however.

     

    $vcenter = "vcenter.domain.com"
    $cred = get-credential
    $licenses = "array","of","license","keys"


    $vc = connect-viserver -server $vcenter -credential $cred


    ## Add Licenses if not already added
    $LicenseManager = get-view ($vc.ExtensionData.content.LicenseManager)
    $existinglicenses = $LicenseManager.licenses.licensekey
    $licensestoadd = $licenses | where-object {$_ -notin $existinglicenses}
    foreach ($license in $licensestoadd)
    {
    write-host"Adding license"+$license
    $LicenseManager.AddLicense($license,$null)
    }

    ## Assign vCenter license to this server
    $majorversion = $vc.version.split(".")[0]
    $vcenterlicense = ($LicenseManager.licenses | where {$_.name -like "*vCenter*" -and $_.name -like "*$majorversion*"} | select -first 1).licensekey ## Select a single vCenter license
    $LicenseAssignmentManager = get-view ($LicenseManager.licenseAssignmentManager)
    $LicenseAssignmentManager.UpdateAssignedLicense($VC.InstanceUuid,$vCenterLicense,$Null)