Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

Powercli Get vCenter assigned licenses report

This is a second part of earlier written article Powercli Get vCenter licenses information, that script will help to collect all the added VMware licenses but doesn't show which system is utilizing the license. Here in this script it helps you to get report of assigned licences information. Using this script is as similar as earlier one. With below commands you load VMware.PowerCLI and login to multiple vCenters. This usage report helps if there are any unassigned licenses (any entity is using evaluation license) for compliance purpose. Many times I have found people install Esxi server or any other system but don't assign license which causes disconnection after evaluation period end.

#1: Unload Hyper-V module
Remove-Module Hyper-V

#2: Load Powercli Module
Import-Module VMware.PowerCLI

#3: Connect to multiple vCenter (Change servername, user and password accordingly)
Connect-VIserver -Server 192.168.34.20 -User administrator@vsphere.local -Password passward
Connect-VIserver -Server marvel.vcloud-lab.com -User administrator@vsphere.local -Password passward

Powercli Get vCenter licenses information
Powercli Get vCenter assigned licenses report

After running the script it give me complete list of information. If the output need to be in csv file use as below.

Get-vSphereLicenseInfo.ps1 | Export-Csv c:\licdata.csv

You can download Get-vSphereAssignedLicensesInfo.ps1 here or from github.com/kunaludapi.

Get-vSphereAssignedLicensesInfo.ps1 vmware powercli vsphere esxi vsan licenses assigned utilize esx wcp package  evalution mode kubernetes enterpise plus add-on vcenter standard report.png.png

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#requires -version 4
<#
.SYNOPSIS
    Get complete license usage information from vCenter Server
.DESCRIPTION
    The Get-vSphereAssignedLicensesInfo.ps1 gets license usage information from vCenter Server. License information ie: vCenter, Esxi, vSAN etc. This information helps if any of there instance is not assigned with Evaluation license.
.PARAMETER File
    Use Export-Csv using pipeline to export data to csv file.
.INPUTS
    VMware.Vim.LicenseManager
    VMware.Vim.LicenseManagerLicenseInfo
.OUTPUTS
    VMware.Vim.LicenseManagerLicenseInfo
.NOTES
  Version:        1.0
  Author:         Kunal Udapi
  Creation Date:  16 May 2020
  Purpose/Change: Gather vCenter Esxi licenses usage information
  Useful URLs: http://vcloud-lab.com
  Tested on below versions:
    vCenter/Esxi: 7.0
    PowerCLI: 12.0
    PowerShell: 5.1
.EXAMPLE
    EntityDisplayName : Stark_Industries
    Name              : VMware vSAN Evaluation Mode
    LicenseKey        : 00000-00000-00000-00000-00000
    EditionKey        : vsan.eval
    ProductName       : VMware VSAN
    ProductVersion    : 7.0
    EntityId          : domain-c1006
    Scope             : db02fe7d-276e-4d4e-812d-a06c058a0a4c

    This script shows information as above information.
#>

<#
Remove-Module Hyper-V
Import-Module VMware.PowerCLI
Connect-VIserver -Server 192.168.34.20 -User administrator@vsphere.local -Password Computer@1
Connect-VIserver -Server marvel.vcloud-lab.com -User administrator@vsphere.local -Password Computer@1
#>

$licenseManager = Get-View $Global:DefaultVIServers.ExtensionData.content.LicenseManager
$licenseAssignmentManager = Get-View $LicenseManager.licenseAssignmentManager
$assignedLicenses = $licenseAssignmentManager.QueryAssignedLicenses($gloabl.defaultviservers.instanceuuid) | Group-Object -Property EntityId, EntityDisplayName, Scope
$licenseUsage = @()
foreach ($license in $assignedLicenses)
{
    $lic = $license.Group[0] #| select EntityDisplayName, EntityId, Scope
    #$assignedLicenses[0].Group[0].AssignedLicense
    $licenseObj = [PSCustomObject]@{
        EntityDisplayName = $lic.EntityDisplayName
        Name = $lic.AssignedLicense.Name
        LicenseKey = $lic.AssignedLicense.LicenseKey
        EditionKey = $lic.AssignedLicense.EditionKey
        ProductName = $lic.AssignedLicense.Properties | Where-Object {$_.Key -eq 'ProductName'} | Select-Object -ExpandProperty Value
        ProductVersion = $lic.AssignedLicense.Properties | Where-Object {$_.Key -eq 'ProductVersion'} | Select-Object -ExpandProperty Value
        EntityId = $lic.EntityId
        Scope = $lic.Scope
    }
    $licenseObj
    $licenseUsage += $licenseObj
}

This is another screenshot how vCenter licenses report shows.

Get-vSphereAssignedLicensesInfo.ps1 vmware powercli vsphere esxi vsan licenses assigned utilized evalution mode kubernetes enterpise plus add-on vcenter standard report.png

Useful Information
Resolved syslog error: Call OptionManager.UpdateValues for object ha-adv-options on ESXi failed
Solved: Esxi server cannot joined into active directory domain
Solved Esxi host disconnected evaluation license expired
Connect-VIServer Error: Invalid server certificate. Use Set-PowerCLIConfiguration

Go Back

Comment

Blog Search

Page Views

4144655

Follow me on Blogarama