<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.4" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Windows PowerShell script for adding IP routes across a VPN</title>
	<link>http://www.webboise.com/windows-powershell-script-for-adding-ip-routes-across-a-vpn/</link>
	<description>Chris Hillman's random rants on IT stuff &#038; life</description>
	<pubDate>Tue,  7 Feb 2012 04:00:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>

	<item>
		<title>by: ifix4u</title>
		<link>http://www.webboise.com/windows-powershell-script-for-adding-ip-routes-across-a-vpn/#comment-30624</link>
		<pubDate>Fri, 08 Oct 2010 20:34:18 +0000</pubDate>
		<guid>http://www.webboise.com/windows-powershell-script-for-adding-ip-routes-across-a-vpn/#comment-30624</guid>
					<description>If the user has the check box under:
right click on vpn
click properties
click networking tab
highlight tcp/ip 
click properties
click advanced
and buried here you find a check box which adds their pptp as a gateway
This causes the script to return 2 answers when findstr for the ip.
this breaks the script bad. Instead of the proposed line. use the following and modify the ip to what you require. This filters it down to one result, making the script work ALWAYS.  

ipconfig &#124; findstr /c:"IP Address. . . . . . . . . . . . : 10.3.1."

enjoy.</description>
		<content:encoded><![CDATA[<p>If the user has the check box under:<br />
right click on vpn<br />
click properties<br />
click networking tab<br />
highlight tcp/ip<br />
click properties<br />
click advanced<br />
and buried here you find a check box which adds their pptp as a gateway<br />
This causes the script to return 2 answers when findstr for the ip.<br />
this breaks the script bad. Instead of the proposed line. use the following and modify the ip to what you require. This filters it down to one result, making the script work ALWAYS.  </p>
<p>ipconfig | findstr /c:&#8221;IP Address. . . . . . . . . . . . : 10.3.1.&#8221;</p>
<p>enjoy.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Add routes on VPN connect with Powershell and Task Scheduler &#171; Simplify</title>
		<link>http://www.webboise.com/windows-powershell-script-for-adding-ip-routes-across-a-vpn/#comment-30533</link>
		<pubDate>Wed, 06 Oct 2010 21:21:54 +0000</pubDate>
		<guid>http://www.webboise.com/windows-powershell-script-for-adding-ip-routes-across-a-vpn/#comment-30533</guid>
					<description>[...] So I thought to my self that there should be a better way to do this. With some basic Googling I quickly came up with an elegant solution. The first step towards the solution was a piece found on this blog. The blog discribes the very same problem that I was facing and provides a simple Powershell script that handles the routes. This Powershell script although it does what is need efficiently didn&#8217;t completely satisfy me. [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] So I thought to my self that there should be a better way to do this. With some basic Googling I quickly came up with an elegant solution. The first step towards the solution was a piece found on this blog. The blog discribes the very same problem that I was facing and provides a simple Powershell script that handles the routes. This Powershell script although it does what is need efficiently didn&#8217;t completely satisfy me. [&#8230;]
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: SkullKiller</title>
		<link>http://www.webboise.com/windows-powershell-script-for-adding-ip-routes-across-a-vpn/#comment-24098</link>
		<pubDate>Tue, 09 Mar 2010 13:33:24 +0000</pubDate>
		<guid>http://www.webboise.com/windows-powershell-script-for-adding-ip-routes-across-a-vpn/#comment-24098</guid>
					<description>Hi.

Here is a ps1 script that takes the interface name, the ip to route and the ipmask and routes an ip trough a interface. It can be a vpn or a normal network card. It utilizes route.exe for route adding and .net for NIC IP determination. It also deletes a route.

param(
        [string] $InterfaceName = "Grupo Visabeira",
        [string] $IP2Route = "192.168.3.138",
        [string] $IPMask = "255.255.255.255",
        [SWITCH] $Delete)
#$delete = $true
IF ($Delete){
    $local:res = route delete $IP2Route
    IF ($local:res -match 'OK!'){"Route $IP2Route Deleted"}
    ELSE{"Error Deleting $IP2Route: $local:res"}
}else{
    [reflection.assembly]::LoadWithPartialName("System.Net") &#124; Out-Null
    $local:nic = [system.net.networkinformation.networkinterface]::GetAllNetworkInterfaces()&#124;Where-Object {$_.name -eq $InterfaceName}
    if ($local:nic.OperationalStatus -eq 'Up') {
        $local:interfaceIP = ($local:nic.GetIPProperties().unicastaddresses&#124;where {$_.ipv4Mask -ne '0.0.0.0'}).Address.IPAddressToString
        if ($local:interfaceIP) {
            $local:res = route add $IP2Route MASK $IPMask $interfaceIP
            IF ($local:res -match 'OK!'){"Interface [$InterfaceName] Connected and Route $IP2Route Added"}
            ELSE{"Error Adding $IP2Route in Interface $InterfaceName : $local:err"}
        }
    }else{"Network Interface [$InterfaceName] Not Connected"}
}</description>
		<content:encoded><![CDATA[<p>Hi.</p>
<p>Here is a ps1 script that takes the interface name, the ip to route and the ipmask and routes an ip trough a interface. It can be a vpn or a normal network card. It utilizes route.exe for route adding and .net for NIC IP determination. It also deletes a route.</p>
<p>param(<br />
        [string] $InterfaceName = &#8220;Grupo Visabeira&#8221;,<br />
        [string] $IP2Route = &#8220;192.168.3.138&#8243;,<br />
        [string] $IPMask = &#8220;255.255.255.255&#8243;,<br />
        [SWITCH] $Delete)<br />
#$delete = $true<br />
IF ($Delete){<br />
    $local:res = route delete $IP2Route<br />
    IF ($local:res -match &#8216;OK!&#8217;){&#8221;Route $IP2Route Deleted&#8221;}<br />
    ELSE{&#8221;Error Deleting $IP2Route: $local:res&#8221;}<br />
}else{<br />
    [reflection.assembly]::LoadWithPartialName(&#8221;System.Net&#8221;) | Out-Null<br />
    $local:nic = [system.net.networkinformation.networkinterface]::GetAllNetworkInterfaces()|Where-Object {$_.name -eq $InterfaceName}<br />
    if ($local:nic.OperationalStatus -eq &#8216;Up&#8217;) {<br />
        $local:interfaceIP = ($local:nic.GetIPProperties().unicastaddresses|where {$_.ipv4Mask -ne &#8216;0.0.0.0&#8242;}).Address.IPAddressToString<br />
        if ($local:interfaceIP) {<br />
            $local:res = route add $IP2Route MASK $IPMask $interfaceIP<br />
            IF ($local:res -match &#8216;OK!&#8217;){&#8221;Interface [$InterfaceName] Connected and Route $IP2Route Added&#8221;}<br />
            ELSE{&#8221;Error Adding $IP2Route in Interface $InterfaceName : $local:err&#8221;}<br />
        }<br />
    }else{&#8221;Network Interface [$InterfaceName] Not Connected&#8221;}<br />
}
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Mick</title>
		<link>http://www.webboise.com/windows-powershell-script-for-adding-ip-routes-across-a-vpn/#comment-15738</link>
		<pubDate>Fri, 08 May 2009 02:23:44 +0000</pubDate>
		<guid>http://www.webboise.com/windows-powershell-script-for-adding-ip-routes-across-a-vpn/#comment-15738</guid>
					<description>Hi mate,

Any idea how to automatically execute that script after a connection has been established to the VPN?</description>
		<content:encoded><![CDATA[<p>Hi mate,</p>
<p>Any idea how to automatically execute that script after a connection has been established to the VPN?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Eugen</title>
		<link>http://www.webboise.com/windows-powershell-script-for-adding-ip-routes-across-a-vpn/#comment-10871</link>
		<pubDate>Tue, 13 Jan 2009 05:40:34 +0000</pubDate>
		<guid>http://www.webboise.com/windows-powershell-script-for-adding-ip-routes-across-a-vpn/#comment-10871</guid>
					<description>Great article.  just what i was looking for.</description>
		<content:encoded><![CDATA[<p>Great article.  just what i was looking for.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>

