From 6e373022df3f8c464972e05f48515216f5058b15 Mon Sep 17 00:00:00 2001 From: Benjamin Rechsteiner Date: Wed, 23 Mar 2022 16:24:46 +0100 Subject: [PATCH] add run as and use temp routes --- sslvpn-route.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sslvpn-route.ps1 b/sslvpn-route.ps1 index 9834250..ac0b2e5 100755 --- a/sslvpn-route.ps1 +++ b/sslvpn-route.ps1 @@ -1,4 +1,4 @@ -#requires -version 5 +#requires -version 5 <# .SYNOPSIS @@ -46,9 +46,10 @@ function Get-GwIp { function Set-Route { $Gw = Get-GwIp Foreach ($ip in $script:IPs) { - $ip_route = "$ip/32" - New-NetRoute -DestinationPrefix $ip_route -NextHop $Gw.NextHop -InterfaceIndex $Gw.ifIndex | Out-Null - Write-Host "Set Route $ip_route through SSLVPN" + Start-Process -FilePath powershell.exe -ArgumentList { + route ADD $ip MASK 255.255.255.255 $Gw.NextHop + } -verb RunAs + Write-Host "Set Route $ip/32 through SSLVPN" } }