Enthusiast
Enthusiast

Powercli to get vSAN cluster license

Hi,

I have been trying to script info about used licenses in vSphere environment. With this command I get what I need:

- vcenter, cluster, host name and license key applied on the host:

get-vmhost | Select @{N="vCenter";E={$_.Uid.Split('@')[1].Split(':')[0]}},Parent,Name,@{N=”LicenseKey”;E={Get-VMHost -Name $_ | Select-Object -Property LicenseKey}}

But for vSAN clusters I couldnt find a way to pull info which vSAN license key is used on which vSAN cluster. Is it even possible?

I don't need general info from vCenter about used keys, I need license info per ESXi host and vSAN license for vSAN cluster.

If someone has a tip, would be nice Smiley Happy

thanks

0 Kudos
5 Replies
Leadership
Leadership

Did you try like this?

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

$LicenseAssignmentManager = Get-View $LicenseManager.LicenseAssignmentManager

$LicenseManager.Licenses |

where{$_.Name -match "VSAN"} |

Select *


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

0 Kudos
Enthusiast
Enthusiast

that lists info about the license itself:

LicenseKey : keyValueXXXX

EditionKey : vsan.enterprise2

Name       : VMware vSAN Enterprise

Total      : 48

Used       : 48

CostUnit   : cpuPackage

Properties : {LicenseInfo, LicenseInfo, LicenseInfo, ProductName...}

Labels     :

But I need to know which key was applied on which vSAN cluster.

0 Kudos
Leadership
Leadership

Ok, try this

$clusterName = 'cluster'

$cluster = Get-Cluster -Name $clusterName


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

$LicenseAssignmentManager = Get-View $LicenseManager.LicenseAssignmentManager

$LicenseAssignmentManager.QueryAssignedLicenses($cluster.ExtensionData.MoRef.Value) |

Select -ExpandProperty AssignedLicense |

where{$_.Name -match 'VSAN'}


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

Enthusiast
Enthusiast

Thanks LucD! (your older answer helped me)

using the following code:

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

$LicenseAssignmentManager = Get-View $LicenseManager.LicenseAssignmentManager

$list = $LicenseAssignmentManager.GetType().GetMethod("QueryAssignedLicenses").Invoke($LicenseAssignmentManager,@($null)) | Select EntityDisplayName,

@{N='Product';E={$_.Properties | where{$_.Key -eq 'ProductName'} | select -ExpandProperty Value}},

@{N='Product Version';E={$_.Properties | where{$_.Key -eq 'FileVersion'} | select -ExpandProperty Value}},@{N='License';E={$_.AssignedLicense.LicenseKey}},

@{N='License Name';E={$_.AssignedLicense.Name}},@{N='Used License';E={$_.Properties | where{$_.Key -eq 'EntityCost'} | select -ExpandProperty Value}},@{N='Total';E={$_.AssignedLicense.Total}}

I am able to get info about ESXi host license and Cluster license in case of vSAN!

      

EntityDisplayNameProductProduct VersionLicenseLicense NameUsed LicenseTotal
ESXi host nameVMware ESX Server6.7.1.0keyValue for ESXi hostVMware vSphere 6 Enterprise Plus2250
Cluster nameVMware VSANkeyValue for vSAN clusterVMware vSAN Advanced2464

In ideal case, I would have vCenter name and cluster name in front of the ESXi host and just vCenter name in front of the cluster.

0 Kudos
Leadership
Leadership

For the record, that way of calling the method on the LicenseAssignmentManager dates from the time when the PowerCLI framework didn't expose the methods yet.

You can now call the method, provided you are using a recent PowerCLI version, the way I showed in my previous reply.


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

0 Kudos