PowerCLI

Expand all | Collapse all

PowerCLI License Manager-UpdateAssignedLicense

  • 1.  PowerCLI License Manager-UpdateAssignedLicense

    Posted Oct 24, 2018 06:29 PM

    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



  • 2.  RE: PowerCLI License Manager-UpdateAssignedLicense

    Posted Oct 24, 2018 06:36 PM

    My fault, I didnt have VSAN enable on that particular cluster yet. For future reference though its the data in $datacenterMoRef.



  • 3.  RE: PowerCLI License Manager-UpdateAssignedLicense

    Posted Nov 12, 2019 03:31 PM

    I am getting the same error and I see in the cluster view that VSAN is enabled

    get-cluster | select vsanenabled

    VsanEnabled               : True

    I don't understand what you mean by  data in $datacenterMoRef



  • 4.  RE: PowerCLI License Manager-UpdateAssignedLicense

    Posted Nov 12, 2019 03:40 PM

    The 1st parameter ($cluster.ExtensionData.MoRef) on the method call.

    No, not really.
    You could check in the vpxd log, there might be some info available.



  • 5.  RE: PowerCLI License Manager-UpdateAssignedLicense

    Posted Nov 12, 2019 09:22 PM

    This was a really fun issue but as per your example does not work for us.  We had to expand the value of the key-value pair for the $cluster.ExtensionData.MoRef which worked for us.

    Here is the VC/Powercli version:

    Version       : 6.7.1

    Build         : 10244857

    PowerCLI Version

    ----------------

       VMware PowerCLI 6.5 Release 1 build 4624819



  • 6.  RE: PowerCLI License Manager-UpdateAssignedLicense

    Posted Nov 12, 2019 10:24 PM

    That is a rather old PowerCLI version.
    I would suggest upgrading, see Welcome PowerCLI to the PowerShell Gallery – Install Process Updates for instructions on that



  • 7.  RE: PowerCLI License Manager-UpdateAssignedLicense

    Posted Oct 24, 2018 06:49 PM

    Works for me.

    Note that the I changed the -contains to a -match, and I use the MoRef.

    $clusterName = 'MyCluster'

    $LicenseManager= Get-View $global:DefaultVIServer.ExtensionData.Content.LicenseManager

    $LicenseAssignmentManager= Get-View $LicenseManager.LicenseAssignmentManager

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


    foreach($license in $LicenseManager.Licenses){

       if($license.Name -match "VSAN"){

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

       $vsanLicenseKey = $license.LicenseKey

       }

       }

    }


    $LicenseAssignmentManager.UpdateAssignedLicense($cluster.ExtensionData.MoRef,$vsanLicenseKey,"VSAN")



  • 8.  RE: PowerCLI License Manager-UpdateAssignedLicense

    Posted Nov 12, 2019 03:32 PM

    Would you know any other reasons why this would be generating the same error above for me?



  • 9.  RE: PowerCLI License Manager-UpdateAssignedLicense

    Posted 8 days ago

    Sorry for bumping 5 years old topic but having the same issue. 

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

    Powercli 13.3, single vCenter connected, single cluster in the variable. Tried $cluster.ID as well - still the same.

    @LucD - any chance you could recommend something to check? 

    Thank you in advance.




  • 10.  RE: PowerCLI License Manager-UpdateAssignedLicense

    Posted May 03, 2022 08:43 PM

    love your stuff, always.  Quick question on this -- on the last line,

    $LicenseAssignmentManager.UpdateAssignedLicense($cluster.ExtensionData.MoRef,$vsanLicenseKey,"VSAN")

    What property is that "VSAN" tag updating exactly?  I have updated several licenses on vSAN clusters & am seeing the asset under the license in vCenter was changed to the name of the license instead of the actual cluster name.



  • 11.  RE: PowerCLI License Manager-UpdateAssignedLicense

    Posted May 03, 2022 08:57 PM

    According to the API Reference that should set the EntityDisplayName (see the UpdateAssignedLicense method).



  • 12.  RE: PowerCLI License Manager-UpdateAssignedLicense

    Posted May 03, 2022 09:04 PM

    Got any tricks for getting that set back to original name?  I now understand using $null for that parameter is what I need to do.  I didn't see this until I started verifying the license was assigned everywhere.



  • 13.  RE: PowerCLI License Manager-UpdateAssignedLicense

    Posted May 03, 2022 09:34 PM

    Besides removing the license and aassigning it again (with the $null value), not really I'm afraid