PowerCLI: vSphere License Export
Seeing Luc’s recent blog post where he explains how to add a vCenter License using PowerCLI, I thought I would stick with the licensing theme and show you how to export your vSphere License keys and details to a csv file enabling you to keep them backed up in a safe place.
This script will only work with vSphere as in vSphere the license server was removed and licensing became a great deal easier, if you want the v3 version you can grab it from my previous post here.
The output can be seen below:
Script:
$filename = “C:\LicenseInformation.csv“
If ((Get-View ServiceInstance).Content.About.Version-ge “4.0.0“){
$ServiceInstance = Get-View ServiceInstance
$LicenseMan = Get-View $ServiceInstance.Content.LicenseManager
$vSphereLicInfo = @()
Foreach ($License in $LicenseMan.Licenses){
$Details = “” |Select Name, Key, Total, Used,Information
$Details.Name= $License.Name
$Details.Key= $License.LicenseKey
$Details.Total= $License.Total
$Details.Used= $License.Used
$Details.Information= $License.Labels |Select -expand Value
$vSphereLicInfo += $Details
}
$vSphereLicInfo |Select Name, Key, Total, Used,Information |Export-Csv -NoTypeInformation $filename
}
Else {
Write “Sorry V4 Only“
}
I have included this in my new VESI PowerPack, the version in the PowerPack will automatically work out if your VI is V3 or V4 and show the appropriate information.






