Advertisement
guyrleech

Get Active Network Routes

Nov 6th, 2023
1,106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## Get "up" network interfaces so can cross reference to network routes
  2. $upInterfaces = @( Get-NetAdapter -IncludeHidden | Where Status -ieq 'Up' )
  3.  
  4. Get-NetRoute -InterfaceIndex $upInterfaces.ifIndex -ErrorAction SilentlyContinue|select @{n='Interface';e={$script:if = ($upInterfaces|Where-Object ifIndex -eq $_.ifIndex);$script:if.Name}},@{n='Description';e={$script:if.InterfaceDescription}},DestinationPrefix,NextHop,InterfaceMetric,RouteMetric,State|sort-object -property interface,DestinationPrefix|format-table -auto          
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement