Skip to content

Tag: NSX

PoSh – NSX Module Update

A new update has been published to the NSX Module which I previously published on GitHub: https://github.com/kmruddy/Powershell/tree/master/Modules/NSXModule

A reference to the first blog post I made concerning the module, including some screenshots of it actually in use: http://thatcouldbeaproblem.com/?p=823

The module has now grown to 31 of the following cmdlets:

Cmdlet Description
Get-NSXController Gathers NSX Controller details from NSX Manager
Get-NSXControllerUpgrade Gathers NSX Controller Upgrade details from NSX Manager
Get-NSXEdge Gathers NSX Edge Node details from NSX Manager
Get-NSXEdgeDefaultRoute Gathers NSX Edge Node default route details from NSX Manager
Get-NSXEdgeFeatures Gathers NSX Edge Feature details from all nodes within NSX Manager
Get-NSXEdgeFirewall Gathers NSX Edge Node firewall details from NSX Manager
Get-NSXEdgeInterfaces Gathers NSX Edge Node’s Interface details from NSX Manager
Get-NSXEdgeNATs Gathers NSX Edge Node NAT details from NSX Manager
Get-NSXEdgeRoutingOverview Gathers NSX Edge Routing Overview details from all nodes within NSX Manager
Get-NSXEdges Gathers NSX Edge Node details from NSX Manager
Get-NSXEdgeStaticRoute Gathers NSX Edge Node static route details from NSX Manager
Get-NSXEdgeUplinks Gathers NSX Edge Uplink details from all nodes within NSX Manager
Get-NSXIPPools Gathers NSX IP Pool details from NSX Manager
Get-NSXIPSets Gathers NSX IP Set details from NSX Manager
Get-NSXLogicalSwitches Gathers NSX Logical Switches and their details from NSX Manager
Get-NSXManager Gathers NSX Manager details
Get-NSXManagerComponents Gathers NSX Manager component details
Get-NSXManagerSSH Gathers NSX Manager SSH component details
Get-NSXScopes Gathers NSX Scopes and their details from NSX Manager
Get-NSXSSOConfig Gathers NSX SSO details from NSX Manager
New-NSXIPPool Creates an NSX IP Pool within NSX Manager
New-NSXIPSet Creates a new NSX IP Set within NSX Manager
New-NSXLogicalSwitch Gathers NSX Logical Switches and their details from NSX Manager
Remove-NSXEdge Deletes an NSX Edge Node from NSX Manager
Remove-NSXIPPool Removes an NSX IP Pool within NSX Manager
Remove-NSXIPSet Removes an NSX IP Set within NSX Manager
Remove-NSXLogicalSwitch Gathers NSX Logical Switches and their details from NSX Manager
Remove-NSXSSOConfig Removes NSX SSO config from NSX Manager
Restart-NSXManager Configures the NSX Manager for reboot
Set-NSXManagerSSH Configures NSX Manager SSH component
Update-NSXEdge Updates the NSX Edge via Update parameter

If you need an automated way of downloading the files into a dedicated directory and importing the module into the current session please see the following:

Note: this was a script that worked in my environment. There is no warranty or support with this script, please use at your own risk.

PoSh – Gathering VMware NSX Info via API

I’ve been lucky enough to get a chance to do some work involving VMware’s NSX product lately. Having watched a bunch of VMworld sessions, live demos and messed around with it in the VMware Hands on Labs I was fairly comfortable in an existing environment. However I’ve gotten fairly used to using Powershell to do most of my work and there doesn’t appear to be much out there in the way of cmdlets or functions.

Chris Wahl has some really good resources regarding using Powershell to do API calls with NSX to both gather controller information (Creating NSX API Calls with PowerShell – Wahl Network) and create/remove virtual network tiers (Leveraging PowerShell to Deploy Virtual Network Tiers with VMware NSX – Wahl Network).

Thanks to Chris’ first post, I’ve taken what he created and built out a couple additional functions and even dumped them all into module form.

An overview of what’s currently included in the module:

Function Name Description
Get-NSXController Will inventory all of your controllers from NSX Manager
Get-NSXController
Get-NSXEdges Will inventory all of your Edge Nodes from NSX Manager
Get-NSXEdges
Get-NSXEdgeFeatures Will inventory all of your Edge Nodes’ Features from NSX Manager
Get-NSXEdgeFeatures
Get-NSXEdgeInterfaces Will inventory the selected Edge Node’s Interfaces from NSX Manager
Get-NSXEdgeInterfaces
Get-NSXEdgeNats Will inventory all of your Edge Node’s NATs from NSX Manager
Get-NSXEdgeNATs
Get-NSXEdgeRoutingOverview Will inventory all of your Edge Nodes’ Routing Overview details from NSX Manager
Get-NSXEdgeRoutingOverview
Get-NSXUplinks Will inventory all of your Edge Nodes’ Uplinks from NSX Manager
Get-NSXEdgeUplinks

A general walk-through of what’s occurring within each function is Powershell using the Invoke-WebRequest cmdlet against the NSX Manager’s REST API and formatting what’s returned into an easy to consume format that is a similar match to what’s returned back by way of the “Networking and Security” plugin.

Requirements:
Powershell 3.0 or better: Invoke-WebRequest first appeared in Powershell version 3.0, so anything less won’t work.
NSX Manager Admin credentials: All of the information is being pulled directly from the NSX Manager
Import the module by way of the .psd1 file: while not really a requirement, it certainly helps with the formatting of the output

Example of how the formatting is handled, first with the .psd1 file then with the .psm1 file:
Loading NSX PSD1 vs PSM1

Link to the GitHub repo location: https://github.com/kmruddy/Powershell/tree/master/Modules/NSXModule

An automated way of downloading the files into a dedicated directory and importing the module into the current session:

Note: this was a script that worked in my environment. There is no warranty or support with this script, please use at your own risk.