VMware Cloud Community
bravestar83
Contributor
Contributor
Jump to solution

Licensing Product Name of esxi host

Hi all!

How do i get the licensing information for a specific host using powercli.

From vCenter it is simple enough host -> configure -> Licensing 

I'm specifically looking from product name.

using 

$vmh = Get-VMHost -Name ”vmhost”
$vmh.ExtensionData.config.product
 
Returns
 
Name : VMware ESXi
FullName : VMware ESXi 7.0.3 build-21686933
Vendor : VMware, Inc.
Version : 7.0.3
PatchLevel : 0.90
Build : 21686933
LocaleVersion : INTL
LocaleBuild : 000
OsType : vmnix-x86
ProductLineId : embeddedEsx
ApiType : HostAgent
ApiVersion : 7.0.3.0
InstanceUuid :
LicenseProductName : VMware ESX Server
LicenseProductVersion : 7.0
 
You would think LicenseProductName is what im looking for but it does not match what is showing in vcenter which is "vSphere 7 Enterprise Plus"
 
Any help would be appreciated
Labels (1)
0 Kudos
1 Solution

Accepted Solutions
Dharzhak
Enthusiast
Enthusiast
Jump to solution

The license information is largely separate from the VMHost object. It's queried from the vCenter License Manager service as the links provided by @LucD show. The "Product Name" is actually the Name property of the license object. A super quick way to query the license your host is using is this way:

> $VIConnection = Connect-VIServer -Server $VIServer -Credential $ViCreds
> $VMHostObj = Get-VMHost -Name "vmhost"
> $LicenseMgr = Get-View $VIConnection.ExtensionData.Content.LicenseManager
> $LicenseMgr.Licenses | Where-Object {$_.LicenseKey -eq $VMHostObj.LicenseKey}


LicenseKey : JUST0-SOME0-RANDM-TEXT0-CHARS
EditionKey : esx.enterprisePlus.cpuPackageCoreLimited
Name : vSphere 7 Enterprise Plus
Total : 18
Used : 12
CostUnit : cpuPackage:32core
Properties : {LicenseInfo, ProductName, ProductVersion, FileVersion...}
Labels :

(The license key is fake for obvious reasons.)

View solution in original post

4 Replies
LucD
Leadership
Leadership
Jump to solution

There are quite a few threads in this community on that subject.
For example
Solved: Re: Unable to get License Info from multiple vCent... - VMware Technology Network VMTN

Re: Fetch ESXi license name & expiration date with... - VMware Technology Network VMTN

A search should produce more examples


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

0 Kudos
Dharzhak
Enthusiast
Enthusiast
Jump to solution

The license information is largely separate from the VMHost object. It's queried from the vCenter License Manager service as the links provided by @LucD show. The "Product Name" is actually the Name property of the license object. A super quick way to query the license your host is using is this way:

> $VIConnection = Connect-VIServer -Server $VIServer -Credential $ViCreds
> $VMHostObj = Get-VMHost -Name "vmhost"
> $LicenseMgr = Get-View $VIConnection.ExtensionData.Content.LicenseManager
> $LicenseMgr.Licenses | Where-Object {$_.LicenseKey -eq $VMHostObj.LicenseKey}


LicenseKey : JUST0-SOME0-RANDM-TEXT0-CHARS
EditionKey : esx.enterprisePlus.cpuPackageCoreLimited
Name : vSphere 7 Enterprise Plus
Total : 18
Used : 12
CostUnit : cpuPackage:32core
Properties : {LicenseInfo, ProductName, ProductVersion, FileVersion...}
Labels :

(The license key is fake for obvious reasons.)

bravestar83
Contributor
Contributor
Jump to solution

Thank you so much! This worked perfectly

 

0 Kudos
bravestar83
Contributor
Contributor
Jump to solution

If anyone is ever interested here is a complete script that exports to csv

$vCenter = Connect-VIServer -Server <vcenter> -User "<username>" -Password "<password>"
$export = @()

$VMHostObj = Get-VMHost
foreach($vmhost in $VMHostObj){
    $LicenseMgr = Get-View $vCenter.ExtensionData.Content.LicenseManager
    $DispL = $LicenseMgr.Licenses | Where-Object {$_.LicenseKey -eq $vmhost.LicenseKey} | Select-Object Name, LicenseKey
    $LicInfo = New-Object -TypeName psobject -Property ([ordered]@{"Host"=$vmhost;"Type"=$DispL.Name;"Key"=$DispL.LicenseKey;})
    $export += $LicInfo
}
$export | Export-Csv -Path "<path>\list.csv" -NoTypeInformation
0 Kudos