$numOfArgs = $args.Length
if ($numOfArgs -gt 2)
{
	$serverIp=$args[0]
	$tap=$args[1]
	for ($i=2; $i -lt $numOfArgs; $i++) {
        $interfaceIndex = $(Get-WMIObject Win32_networkadapter | Where ServiceName -eq "tap0901" | Select -ExpandProperty InterfaceIndex)
        $ips=$(Get-WmiObject Win32_IP4RouteTable) | Where-Object {($_.InterfaceIndex -eq $interfaceIndex) -and ($_.NextHop -eq $serverIp)} | Select -ExpandProperty Name
        foreach ($ip in  $ips) {
		    netsh interface ipv4 delete address "$tap" addr=$ip gateway=all | out-null
		    route delete $ip if $interfaceIndex | out-null
        }
        route add $args[$i] mask 255.255.255.0 $serverIp if $interfaceIndex | out-null
	}
}