Using PowerNSX to get all routes on NSX Edges

This is going to be a short one! I received an interesting question from Sander Martijn about retrieving all IP routes from an NSX Edge. There is no API endpoint available in NSX to get the current routes and the only way this information can get retrieved is using the NSX Central CLI. You can easily see all routes on the Central CLI by using the command: show edge edge-id ip route.

PowerNSX has an Invoke-NsxCli cmdlet which executes the Central CLI with a specific query. Because of this, you can retrieve the routes with a PowerShell script and do things with the output.

I put together a quick example that can be used to iterate through all NSX Edges and then use the NSX Central CLI to retrieve the IP routes from it. Check out the GitHub Git below for the code:



Share the wealth!

1 Comment

  1. Hi Matrijn,

    Had a similar use case where I had to check BGP peering status of 40+ ESGs . There is no api endpoint available for that. Invoke-NsxCli cmdlet was of great help

Leave a Reply

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

© 2024 Lostdomain

Theme by Anders NorénUp ↑