lElOUCHE_79
Enthusiast
Enthusiast

add Licences features details to report

Hi folks :slightly_smiling_face:

I find the below script on the internet and I would need assistance to add licenses features details is that possible?

 

foreach ($licenseManager in (Get-View LicenseManager)) #-Server $vCenter.Name
{
    $vCenterName = ([System.uri]$licenseManager.Client.ServiceUrl).Host
    #($licenseManager.Client.ServiceUrl -split '/')[2]
    foreach ($license in $licenseManager.Licenses)
    {
        $licenseProp = $license.Properties
        $licenseExpiryInfo = $licenseProp | Where-Object {$_.Key -eq 'expirationDate'} | Select-Object -ExpandProperty Value
        if ($license.Name -eq 'Product Evaluation')
        {
            $expirationDate = 'Evaluation'
        } #if ($license.Name -eq 'Product Evaluation')
        elseif ($null -eq $licenseExpiryInfo)
        {
            $expirationDate = 'Never'
        } #elseif ($null -eq $licenseExpiryInfo)
        else
        {
            $expirationDate = $licenseExpiryInfo
        } #else #if ($license.Name -eq 'Product Evaluation')
    
        if ($license.Total -eq 0)
        {
            $totalLicenses = 'Unlimited'
        } #if ($license.Total -eq 0)
        else 
        {
            $totalLicenses = $license.Total
        } #else #if ($license.Total -eq 0)
    
        $licenseObj = New-Object psobject
        $licenseObj | Add-Member -Name Name -MemberType NoteProperty -Value $license.Name
        $licenseObj | Add-Member -Name LicenseKey -MemberType NoteProperty -Value $license.LicenseKey
        $licenseObj | Add-Member -Name ExpirationDate -MemberType NoteProperty -Value $expirationDate
        $licenseObj | Add-Member -Name ProductName -MemberType NoteProperty -Value ($licenseProp | Where-Object {$_.Key -eq 'ProductName'} | Select-Object -ExpandProperty Value)
        $licenseObj | Add-Member -Name ProductVersion -MemberType NoteProperty -Value ($licenseProp | Where-Object {$_.Key -eq 'ProductVersion'} | Select-Object -ExpandProperty Value)
        $licenseObj | Add-Member -Name EditionKey -MemberType NoteProperty -Value $license.EditionKey
        $licenseObj | Add-Member -Name Total -MemberType NoteProperty -Value $totalLicenses
        $licenseObj | Add-Member -Name Used -MemberType NoteProperty -Value $license.Used
        $licenseObj | Add-Member -Name CostUnit -MemberType NoteProperty -Value $license.CostUnit
        $licenseObj | Add-Member -Name Labels -MemberType NoteProperty -Value $license.Labels
        $licenseObj | Add-Member -Name vCenter -MemberType NoteProperty -Value $vCenterName
        $licenseObj
    } #foreach ($license in $licenseManager.Licenses)
} #foreach ($licenseManager in (Get-View LicenseManager)) #-Server $vCenter.Name
Reply
0 Kudos
LucD
Leadership
Leadership

Add the following line

		$licenseObj | Add-Member -Name Features -MemberType NoteProperty -Value (($license.Properties.Where{ $_.Key -eq 'feature' }).Value.Value -join '|')


PS: it is always nice when you refer to a script to include a link


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

View solution in original post

lElOUCHE_79
Enthusiast
Enthusiast

@LucDit's working thanks :slightly_smiling_face:

Just a question, do you know a way to have the feature in single line?

Like this :

Unlimited virtual SMP
H.264 for Remote Console Connections
vCenter agent for VMware host
.

.

.

.

Reply
0 Kudos
LucD
Leadership
Leadership

Join with a NL character

		$licenseObj | Add-Member -Name Features -MemberType NoteProperty -Value (($license.Properties.Where{ $_.Key -eq 'feature' }).Value.Value -join "`n")


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

View solution in original post

lElOUCHE_79
Enthusiast
Enthusiast

Thank you @LucD 

Reply
0 Kudos