License NSX via automation with PowerCLI

Quick one today. As of NSX 6.2.3 and 6.2.4 onwards there are licensing tiers. Standard, Advanced, and Enterprise unlock a different set of features. Whilst I won’t hop on the soap box about that today (buy me a beer and I will) there have been lots of automation efforts using PowerNSX to deploy NSX.

With the advent of licensing, the automated installs of 6.2.0 – 6.2.2 that myself and others have been working on came to a screeching halt. All well and good but I needed a way around this. NSX needs to be licensed to prepare the cluster for NSX VIBs to be installed.

# NSX licence via PowerCLI
#a. anthony burke
#t. @pandom
#c. This script will licence NSX for vSphere via PowerCLI. It requires a connection to vCenter along with a valid licence. Kudos to Gavin for helping me find nsx-netsec via MOB.

param (

$ServiceInstance = Get-View ServiceInstance
$LicenseManager = Get-View $ServiceInstance.Content.licenseManager
$LicenseAssignmentManager = Get-View $LicenseManager.licenseAssignmentManager

# The following can be used to check an assigned licence. 
#$CheckLicense = $$LicenseAssignmentManager.QueryAssignedLicenses("nsx-netsec")

Thanks to Gavin B at VMware to directing me to the MOB to find the nsx-netsec service instance ID. Here is the simple script that will do the following:

  • Retrieve and store the licence manager and licence assignment manager objects as variables.
  • Append the value “nsx-netsec” and the value of $licence to the licence assessment manager variable.

That’s it. License is enabled. Voila!

From an automation perspective this needs to be done after the NSX Manager has been registered to vCenter but before Host Preparation is done.

Get the code here on GitHub.

Leave a Reply

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