VMware Cloud Community
SonNguyen1
Contributor
Contributor

PowerCLI License Manager-UpdateAssignedLicense

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

Tags (1)
Reply
0 Kudos
11 Replies
SonNguyen1
Contributor
Contributor

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

Reply
0 Kudos
LucD
Leadership
Leadership

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")


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
konfigurationk2
Contributor
Contributor

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

Reply
0 Kudos
konfigurationk2
Contributor
Contributor

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

Reply
0 Kudos
LucD
Leadership
Leadership

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.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
konfigurationk2
Contributor
Contributor

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

Reply
0 Kudos
LucD
Leadership
Leadership

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
srainbolt2
Contributor
Contributor

@LucDlove 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.

Reply
0 Kudos
LucD
Leadership
Leadership

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

srainbolt2
Contributor
Contributor

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.

Reply
0 Kudos
LucD
Leadership
Leadership

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos