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
thanks
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
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.
Ok, try this
$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
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!
EntityDisplayName | Product | Product Version | License | License Name | Used License | Total |
---|---|---|---|---|---|---|
ESXi host name | VMware ESX Server | 6.7.1.0 | keyValue for ESXi host | VMware vSphere 6 Enterprise Plus | 2 | 250 |
Cluster name | VMware VSAN | keyValue for vSAN cluster | VMware vSAN Advanced | 24 | 64 |
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.
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