VMware Cloud Community
thiag2011
Enthusiast
Enthusiast
Jump to solution

Command to get license key information of a host

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

1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

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.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

0 Kudos
18 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

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.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
thiag2011
Enthusiast
Enthusiast
Jump to solution

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 !!!

0 Kudos
Naveenreddy028
Contributor
Contributor
Jump to solution

Hi

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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Did you try this?

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


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

0 Kudos
nicholas1982
Hot Shot
Hot Shot
Jump to solution

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?

Nicholas
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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


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

0 Kudos
nicholas1982
Hot Shot
Hot Shot
Jump to solution

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.

Nicholas
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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


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

0 Kudos
nicholas1982
Hot Shot
Hot Shot
Jump to solution

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?

Nicholas
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

$licMgr = Get-View licensemanager

$licMgr.Licenses


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

0 Kudos
nicholas1982
Hot Shot
Hot Shot
Jump to solution

As always thanks again for your help.

Nicholas
0 Kudos
gmadro
Contributor
Contributor
Jump to solution

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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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 }}

    }

}


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

gmadro
Contributor
Contributor
Jump to solution

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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Submit the idea!
VMware PowerCLI


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

0 Kudos
gmadro
Contributor
Contributor
Jump to solution

0 Kudos
DDHB
Contributor
Contributor
Jump to solution

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!

0 Kudos
virtsysadmin
Enthusiast
Enthusiast
Jump to solution

Thanks.. worked for Me


I am a VMware employee, But I contribute to VMTN voluntarily (ie. not in any official capacity)
VCIX-DCV 2020|CKA|VCP|VCP vSphere 7|MCTS|RHCA|CCNA|ITIL| Master Specialist - VMware Cloud on AWS 2021
Please hit resolved, when your question has been answered.
0 Kudos