7 Replies Latest reply on Nov 12, 2019 2:23 PM by LucD

    PowerCLI License Manager-UpdateAssignedLicense

    SonNguyen1 Lurker

      I tried running the following commands to try and add a VSAN license to a cluster but it keeps failing at the UpdateAssignedLicense

      $LicenseManager= Get-View $server.ExtensionData.Content.LicenseManager

      $LicenseAssignmentManager= Get-View $LicenseManager.LicenseAssignmentManager

      $cluster = Get-Cluster -Server $server -Name $clusterName


      foreach($license in $LicenseManager.Licenses){

      >>     if($license.Name -contains "VMware vSAN Standard for Retail and Branch Offices"){

      >>         if($license.Total -gt $license.Used){

      >>             $vsanLicenseKey = $license.LicenseKey;

      >>             break;

      >>         }

      >>     }

      >> }


      $LicenseAssignmentManager.UpdateAssignedLicense($cluster.id,$vsanLicenseKey,"VMware vSAN Standard for Retail and Branch Offices")


      I keep getting the following errors:

      Exception calling "UpdateAssignedLicense" with "3" argument(s): "A specified parameter was not correct: entityId"

      At line:1 char:1

      + $LicenseAssignmentManager.UpdateAssignedLicense($datacenterMoRef.valu ...

      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

          + FullyQualifiedErrorId : VimException


      I tried the following: $cluster.id, $cluster.ExtensionData.MoRef, and even $datacenterMoRef = (Get-Cluster -Server $server -Name $clusterName | get-view).MoRef.value

      They all throw the same error. What is the entityId that I should be using with respect to cluster?


      PowerCLI 6.5 Release 1 build 4624819

      vCenter 6.5