, ,

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,


Post a Comment