Automation

 View Only
  • 1.  Licensing Product Name of esxi host

    Posted Jun 08, 2023 07:46 PM

    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


  • 2.  RE: Licensing Product Name of esxi host

    Posted Jun 09, 2023 12:00 PM


  • 3.  RE: Licensing Product Name of esxi host
    Best Answer

    Posted Jun 12, 2023 10:06 PM

    The license information is largely separate from the VMHost object. It's queried from the vCenter License Manager service as the links provided by  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.)



  • 4.  RE: Licensing Product Name of esxi host

    Posted Oct 19, 2023 09:50 AM

    Thank you so much! This worked perfectly

     



  • 5.  RE: Licensing Product Name of esxi host

    Posted Oct 19, 2023 01:32 PM

    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