Was checking my Windows 8 machine routing table (route print
) when I noticed many entries like this:
1 2 3 4 5 6 7 8 |
5.63.150.60 255.255.255.255 192.168.1.1 192.168.17.207 25 46.165.208.207 255.255.255.255 192.168.1.1 192.168.17.207 25 46.165.221.13 255.255.255.255 192.168.1.1 192.168.17.207 25 46.165.251.69 255.255.255.255 192.168.1.1 192.168.17.207 25 64.237.37.124 255.255.255.255 192.168.1.1 192.168.17.207 25 66.55.150.181 255.255.255.255 192.168.1.1 192.168.17.207 25 81.17.27.234 255.255.255.255 192.168.1.1 192.168.17.207 25 108.61.55.77 255.255.255.255 192.168.1.1 192.168.17.207 25 |
Not sure what they are. I didn’t create them, and the 192.168.1.1 address is not on my network.
To be on the safe side I wanted to remove them. One could do it via route delete but that’s so old fashioned and slow (I would have to do it for each entry). What I want is a quick and easy way of mass removing routes. Enter the routing table related cmdlets in PowerShell 3.0.
The following one-liner will remove all routes whose NextHop address is 192.168.1.1:
1 |
Get-NetRoute | ?{ $_.NextHop -eq "192.168.1.1" } | Remove-NetRoute |
Easy peasy!
For PowerShell 2.0 am sure there would be a WMI way of achieving the same. Will post that later.