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)
0 Kudos
7 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.

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

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

0 Kudos
konfigurationk2
Contributor
Contributor

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

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

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

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

0 Kudos