Skip to main content

PowerNSX | Add mulitple static route in NSX Edge

Good Day Folks,

During one of the activity, I had a requirement to put multiple (20-25) static routes on NSX edge and doing it one by one and manually is a headache, you know that. right?

So, I thought to do it through power NSX. Below is the code-

#Start here

Connect-NSXServer -NSXserver
$nsxedges = (Get-nsxedge -objectid edge-3).id
$subnets = '',''      #add all the network which you want to add in static route
$nexthop = ''

Foreach($subnet in $subnets){
Foreach($nsxedge in $nsxedges){

Get-NsxEdge -ObjectId $nsxedge | Get-NsxEdgerouting | New-NsxEdgeStaticRoute -vNic 0 -Network $subnet -NextHop $nexthop -MTU 9000 -AdminDistance 1 -Confirm:$false
#End here

Refer to below output for an example

Hope it will help you. Let me know if any doubt or any error.

Thank you,


Popular posts from this blog

Network Migration | VLAN to VXLAN

NSX-T | Getting Started with PowerCLI

NSX-T | Security

Automate Power on Operations using PS