Using PowerCLI to Add vRealize Operations License Key

Share on:

I have been working on doing a vCenter Consolidation Project. This included migrating our systems to a new vRealize Operations Server. This particular one included 73 different vSOM keys, and as you may know there is currently no way to enter in multiple keys at a time. I reached out to Kyle Ruddy and he informed me there is an API to do this, and that started my adventure to get this working.

Pre-Requsites

Preparing to Execute the Script

The script is pretty straight forward, you can either export the license keys from an old vRealize Operations Server (6.6+) or create a CSV with column (LicenseKey) to be imported.

If you are choosing to export keys from an existing server, it has to be on a version that currently has API support. (I used v6.6)

You can run the following script to export all keys to a csv file.

1$Cred = Get-Credential
2$vrom = "vromold.lab.local"
3
4Connect-OMServer -Server $vrom -Credential $Cred
5
6$omServer = $global:DefaultOMServers[0].ExtensionData
7$omLicense = $OmServer.GetLicenseKeysForProduct()
8$omLicense.Solutionlicense|Export-Csv C:\temp\omkeys2.csv -NoTypeInformation

If you exported the keys above, you should be immediately ready to import the keys to your new vRealize Operations Server, if not you can manually create the csv as listed above.

 1$Cred = Get-Credential
 2$vrom = "vromnew.lab.local"
 3
 4Connect-OMServer -Server $vrom -Credential $Cred
 5
 6$keys = import-csv c:\temp\omkeys.csv
 7foreach ($key in $keys) {
 8    $solutionLicense = New-Object VMware.VimAutomation.VROps.Views.SolutionLicense
 9    $solutionLicense.LicenseKey = $key.LicenseKey
10    $solutionLicenses = New-Object VMware.VimAutomation.VROps.Views.SolutionLicenses
11    $solutionLicenses.Solutionlicense = $solutionLicense
12    $omserver.AddLicenseKeyToProduct($solutionLicenses)
13}

The documentation was pretty spotty on this as it stated you only needed to pass the key to AddLicenseKeyToProduct(), but after multiple tests I realized that was not true. I eventually found out i have to create SolutionLicense objects and link them till i got the proper format. This was quite fun as i learned alot about PowerShell and API documentation in this process.

You can find API documentation for vRealize Operations at https://fqdn/suite-api/docs/rest/index.html

Hope this helps you out, leave any feedback or questions below.

comments powered by Disqus

See Also