Please enable Javascript for better experience...
Script to pull the licensing information from multiple Vcenter
By Jitendra | Apr 25, 2020 | In Articles | Total Views [ 3898 ]
(0 Like)
Rate

intial description

Script to pull the licensing information from multiple Vcenter

This scripts will pull the licensing inforamtion from the mulitple Vcenter and export it in the csv file.

Hope this will be useful for you. Removing the Key column for security purpose.

Find the sample report as below.

VC Name Key Total Used ExpirationDate Information
hmtvcsa03 Product Evaluation   0      
hmtvcsa03 VMware vSphere 7 Enterprise Plus   16 4 3/10/2021 0:00  
hmtvcsa03 VMware vCenter Server 7 Standard   16 1 3/10/2021 0:00  
hmtvcsa01 Product Evaluation   0      
hmtvcsa01 VMware vSphere 6 Enterprise Plus   0 6    
hmtvcsa01 VMware vSphere 6 Standard   0 0    
hmtvcsa01 NSX for vSphere - Standard   16 0 4/30/2020 0:00  
hmtvcsa01 VMware vCenter Server 6 Standard   0 1    
hmtvcsa01 NSX for vShield Endpoint   0 0    
hmtvcsa01 VMware vSphere 6 Hypervisor   0 0    
hmtvcsa02 Product Evaluation   0      
hmtvcsa02 VMware vSphere 6 Enterprise Plus   0 0    
hmtvcsa02 VMware vCenter Server 6 Standard   0 1    

Find the below script code.

--------------------------------------------------------------------------------------------------------------------------------------------

Import-Module VMware.VimAutomation.Core
$Vcenter= get-content Vcenter.txt
foreach ($vmhost in $Vcenter)
{
Connect-VIServer $Vmhost -User administrator@vsphere.local -Password Vcenter@1234
if(((Get-PowerCLIConfiguration).DefaultVIServerMode) -ne "Multiple") {
    Set-PowerCLIConfiguration -DefaultVIServerMode Multiple | Out-Null
}

$vSphereLicInfo = @()
$ServiceInstance = Get-View ServiceInstance
Foreach ($LicenseMan in Get-View ($ServiceInstance | Select -First 1).Content.LicenseManager) {
    Foreach ($License in ($LicenseMan | Select -ExpandProperty Licenses)) {
        $Details = "" |Select VC, Name, Key, Total, Used, ExpirationDate , Information
        $Details.VC = ([Uri]$LicenseMan.Client.ServiceUrl).Host
        $Details.Name= $License.Name
        $Details.Key= $License.LicenseKey
        $Details.Total= $License.Total
        $Details.Used= $License.Used
        $Details.Information= $License.Labels | Select -expand Value
        $Details.ExpirationDate = $License.Properties | Where { $_.key -eq "expirationDate" } | Select -ExpandProperty Value
        $vSphereLicInfo += $Details
    }
}
}
$vSphereLicInfo | export-csv lic.csv -NoTypeInformation

---------------------------------------------------------------------------------------------------------------------------------------------------

Rest mandatory requirement would remain same to run a powercli script.

Thanks

Share this

About the Author

Jitendra
Jitendra
Contributer VMwareDiary.com

User's Comments


 
Please SignUp/Login to comment...

Or comment as anonymous...
* Name
* Email ID
Comment