VMware NSX has an open API and it’s pretty easy to consume. PowerShell is the same way; it’s easy to learn and easy to extend. This week, Anthony Burke and Nick Bradford released a PowerShell extension called PowerNSX. As the name suggests, it’s all about managing VMware NSX.

Nick and Anthony put PowerNSX on Bitbucket, which means there will be a continuos release cycle (whenever someone pushes something to the Git repository). You can download and install PowerNSX using Git or by downloading the branch as a zipfile.

Prerequisites

To run PowerNSX, you need a couple of things pre-installed on your machine. PowerShell v3+, .NET 4.5+, PowerCLI and the PowerNSX Module. The good news is that PowerNSX provides an installer script that you can use to use to install all of those at once. It’s as easy as executing the installer script, on which it will look for the prerequisites and only download and install the packages that are not installed yet. Here’s what it does:

Using PowerNSX

After installing the PowerNSX module, you can start using the NSX commandlets. Firstly include the PowerCLI Snap-in, then load the PowerNSX module and connect to your NSX Manager.

PowerNSX requiresaPowerCLI connection to the vCenter server NSX is registered against forproper operation.

Automatically create PowerCLI connection to vcenter.lab.local?

[Y]Yes[N]No[?]Help(default is"N"):Y

Enter credentials forvCenter vcenter.lab.local

cmdlet Get-Credentialat command pipeline position1

Supply values forthe following parameters:

Credential

Version:6.2.0

BuildNumber:2986609

Credential:System.Management.Automation.PSCredential

Server:nsx-manager.lab.local

Port:443

Protocol:https

ValidateCertificate:False

VIConnection:vcenter.lab.local

PSD:\Powershell\PowerNSX>

The vCenter configuration is automatically detected from the settings on the NSX Manager and a connection is made to make it easier for PowerNSX to work with vCenter objects such as virtual machines, clusters, dvs, etc.

Examples

When you’re connected to both the NSX Manager and vCenter, you can start doing all kinds of fun stuff. For instance, getting all the NSX Logical Switches in object form:

Martijn Smit

With over 15 years of experience in designing and deploying datacenter environments on all layers, Martijn now works as a NSX Specialist at VMware Benelux.He is a Cisco’s CCNP Datacenter, VMware VCIX-NV, VCP-DCV, VCP-CMA, VCAP-DCA, VCAP-DCD, VSP, VTSP, VMware vExpert (2015-2017, Cloud & NSX) and Cisco Champion (2015-2017).