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:

image

Script:

$filename="C:\LicenseInformation.csv"
$ServiceInstance=Get-View ServiceInstance
$LicenseMan=Get-View $ServiceInstance.Content.LicenseManager
$vSphereLicInfo= @()
Foreach ($Licensein$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-expandValue
	$vSphereLicInfo+=$Details
}
$vSphereLicInfo |Select Name, Key, Total, Used,Information | Export-Csv -NoTypeInformation $filename

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.

image

5 thoughts on “PowerCLI: vSphere License Export

  1. Chids

    hi Al, Have been a great fan of yours and also of the PowerCLI community. I had a query as to why this license reporting script shows the Product Evaluation licenses even though there are no hosts with this eval licenses being used and how to get rid of it.
    Appreciate your help on the same.
    thx

  2. Pingback: VMware vSphere Blog: Retrieving vSphere License Information & Expiration using the vSphere API | Strategic HR

  3. Pingback: VMware vSphere Blog: Retrieving vSphere License Information & Expiration using the vSphere API | Virtualization

  4. Pingback: Retrieving vSphere License Information & Expiration using the vSphere API | VMware vSphere Blog - VMware Blogs

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.