VMware Cloud Community
HHHsien
Contributor
Contributor
Jump to solution

Export all Licenses info + rename with PowerCLI

Hi

I'm trying to export my licenses information to a CSV file using this script :

$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

$Details.VC = ([Uri]$LicenseMan.Client.ServiceUrl).Host

$Details.Name= $License.Name

$Details.Key= $License.LicenseKey

$Details.Total= $License.Total

$Details.Used= $License.Used 

$vSphereLicInfo += $Details

}

}

But I can't export information in the column below :

pastedImage_0.png

I also want to rename a License with PowerCLI (couldn't find anything about it)

Please help me,

Thanks ,

JN

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Afaik you can't get at the Name, again no public API afaik


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

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Which vSphere version are you using?

This seems to work for me (but that is in vSphere 6.5)

$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

        $Details.VC = ([Uri]$LicenseMan.Client.ServiceUrl).Host

        $Details.Name= $License.Name

        $Details.Key= $License.LicenseKey

        $Details.Total= $License.Total

        $Details.Used= $License.Used

        $vSphereLicInfo += $Details

    }

}

$vSphereLicInfo | Export-Csv .\report.csv -UseCulture

Afaik, there is no public API to rename a license entry


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

0 Kudos
HHHsien
Contributor
Contributor
Jump to solution

Thank you Luc,

I'm using vSphere 6.5 and it works fine but that "License" column is missing (License's name)

$Details.Name= $License.Name

That line returns the product's name not the license's name

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Afaik you can't get at the Name, again no public API afaik


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

0 Kudos
HHHsien
Contributor
Contributor
Jump to solution

Ok, that's good to know.

Thank you Luc for your help,

Have a good day

0 Kudos