Automation

 View Only
Expand all | Collapse all

Command to get license key information of a host

  • 1.  Command to get license key information of a host

    Posted Sep 19, 2016 10:25 AM

    Hi,

    I would like to fetch the license key of a single host

    Am able to fetch list of license keys assigned in a vcenter, but unable to fetch host wise.

    My requirement is , i will be connecting to vcenter and need to fetch license key for a single host which i feed as input.

    Please help



  • 2.  RE: Command to get license key information of a host
    Best Answer

    Posted Sep 19, 2016 11:30 AM

    The following PowerCLI command will return the name and license key for a host named ESX1:

    Get-VMHost -Name ESX1 | Select-Object -Property Name,LicenseKey

    You need at least PowerCLI version 5.5 Release 1 for the preceding command to work.



  • 3.  RE: Command to get license key information of a host

    Posted Sep 19, 2016 01:09 PM

    oh yes.... Thanks RvdNieuwendijkRvdNieuwendijk

    I was checking in get-Licensedatamanager and trying all other possible options via get-view, but missed this basic check..

    Thanks a lot !!!



  • 4.  RE: Command to get license key information of a host

    Posted Jan 18, 2018 07:32 AM

    Hi

    I need to get Licence of all the host from VC is there any command



  • 5.  RE: Command to get license key information of a host

    Posted Jan 18, 2018 07:40 AM

    Did you try this?

    Get-VMHost | Select-Object -Property Name,LicenseKey



  • 6.  RE: Command to get license key information of a host

    Posted Feb 09, 2018 04:30 AM

    Hi Luc,

    I have keys added to vCenter, each key represents a cluster, is there any scripted method to apply a key to a host I could then loop for every host in a cluster?



  • 7.  RE: Command to get license key information of a host

    Posted Feb 09, 2018 07:23 AM

    How would you pick which key goes to which cluster, or would that be random?



  • 8.  RE: Command to get license key information of a host

    Posted Feb 09, 2018 08:12 AM

    When the keys are added to VCE ether I name them with the “cluster name - vSphere 6 Enterprise”

    I was hoping to get key and assign to each host in a loop for that particular cluste.



  • 9.  RE: Command to get license key information of a host

    Posted Feb 09, 2018 09:14 AM

    I'm afraid you don't have access to those labels from the cmdlets nor the API.
    You could store them in an external file, and then use the Label from there to pick the cluster and key



  • 10.  RE: Command to get license key information of a host

    Posted Feb 09, 2018 09:42 AM

    Oh wait are you saying you can call it by the actual key, cause if so that’s fine because have a csv with all the labels and keys?



  • 11.  RE: Command to get license key information of a host

    Posted Feb 09, 2018 09:45 AM

    Yes, but check it out with the following to make sure.

    $licMgr = Get-View licensemanager

    $licMgr.Licenses



  • 12.  RE: Command to get license key information of a host

    Posted Feb 09, 2018 09:46 AM

    As always thanks again for your help.



  • 13.  RE: Command to get license key information of a host

    Posted Feb 14, 2018 07:17 PM

    Luc,

    Is there a way to see the License assigned to a particular VC?

    In a linked mode setup when you look at the license manager you will get all of the licenses but not what VC they are assigned to.

    Get-View licensemanager will display all licenses but not what they are assigned to, unless I am missing something.

    I am able to get the Information for each host through get-vmhost but i do not see the equivalent for VC

    Thanks,

    Greg



  • 14.  RE: Command to get license key information of a host

    Posted Feb 14, 2018 07:47 PM

    Try like this

    foreach($vc in $global:DefaultVIServers){

        $licMgr = Get-View LicenseManager -Server $vc

        $licAssignmentMgr = Get-View -Id $licMgr.LicenseAssignmentManager -Server $vc

        $licAssignmentMgr.QueryAssignedLicenses($vc.InstanceUid) | %{

            $_ | select @{N='vCenter';E={$vc.Name}},EntityDisplayName,

                @{N='LicenseKey';E={$_.AssignedLIcense.LicenseKey}},

                @{N='LicenseName';E={$_.AssignedLicense.Name}},

                @{N='ExpirationDate';E={$_.AssignedLicense.Properties.where{$_.Key -eq 'expirationDate'}.Value }}

        }

    }



  • 15.  RE: Command to get license key information of a host

    Posted Feb 15, 2018 02:25 PM

    Luc,

    This code worked very well for me. Thank you.

    It is too bad that a LicenseKey attribute is not a part of the vCenter object such as it is the ESXi host object



  • 16.  RE: Command to get license key information of a host

    Posted Feb 15, 2018 02:57 PM

    Submit the idea!
    VMware PowerCLI



  • 17.  RE: Command to get license key information of a host

    Posted Feb 15, 2018 03:15 PM


  • 18.  RE: Command to get license key information of a host

    Posted May 21, 2018 08:37 PM
    Thanks.. worked for Me


  • 19.  RE: Command to get license key information of a host

    Posted Apr 10, 2018 06:46 PM

    Sorry to revive an older post but I'm having terrible time trying to find the get-view equivalent of this command. It must be buried somewhere in Get-View output?

    Thanks!