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
My fault, I didnt have VSAN enable on that particular cluster yet. For future reference though its the data in $datacenterMoRef.
Works for me.
Note that the I changed the -contains to a -match, and I use the MoRef.
$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
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
Would you know any other reasons why this would be generating the same error above for me?
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
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
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
@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.
According to the API Reference that should set the EntityDisplayName (see the UpdateAssignedLicense method).
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.
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