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

-Alan

Alan

Alan Renouf has a role of Automation Frameworks Product Manager at VMware responsible for providing the architects and operators of the cloud infrastructure with the toolkits/frameworks and command-line interfaces they require to build a fully automated software-defined datacenter. Alan is a frequent blogger at http://blogs.vmware.com/vipowershell and has a personal blog at http://virtu-al.net. You can follow Alan on twitter as @alanrenouf.

You may also like...

4 Responses

  1. JOhn says:

    Any way to pull license expires data also?

  1. December 12, 2012

    [...] you are interested in a similar script but using PowerCLI, here is a script written by my colleague Alan Renouf which exports the licenses to an excel spreadsheet. You can of [...]

  2. December 12, 2012

    [...] you are interested in a similar script but using PowerCLI, here is a script written by my colleague Alan Renouf which exports the licenses to an excel spreadsheet. You can of [...]

  3. December 14, 2012

    [...] you are interested in a similar script but using PowerCLI, here is a script written by my colleague Alan Renouf which exports the licenses to an excel spreadsheet. You can of [...]

Leave a Reply

%d bloggers like this: