Connect Secure 1.0

PowerShell script that makes it easy to connect to secure VPN network and browse some web site within it or launch an application. Should it be work, home or whatever. Best part of it - that it is totally secure. It is simple and open. It also resets connections upon launch. 

To use it - you only need Mozilla browser (just in case if you want something different, it could be Opera, Chrome, or any other executable, like game or crypo-miner) and VPN connection preset! Just it.

Below, everything... Don't forget to leave some feedback!

Here it comes.

Download zip archive with usage examples from here. Command file and shortcuts are just inside. 

To do:

1. Set path to your browser or whatever executable (in the example below path to Mozilla)...

2. Create and store VPN connection details (in the example below it named "Secure")

Finally, code is right here... Your enhancement suggestions are very welcome!

Write-Host "Number of command line arguments:" $args.Count;

if($args.Count -ilt 1)
{
    $ConnectionName="Secure"
    $Execute="C:\Program Files\Mozilla Firefox\firefox.exe"
    $Params="www.whatismyipaddress.com"
}
else {
    if($args.Count -eq 1) {
        $ConnectionName="Secure"
        $Execute="C:\Program Files\Mozilla Firefox\firefox.exe"
        $Params=$args[0]
        }
        else {
                $ConnectionName=$args[0]
                $Execute=$args[1]
                $Params=$args[2]
               
        }
    }

Write-Host "Connection name: $ConnectionName"
Write-Host "Execute:         $Execute"
Write-Host "Parameters:      $Params"

rasdial.exe $ConnectionName

Write-host "Renewing IP configuration..."
ipconfig /renew

Write-host "Launching $Execute $Params"
cmd /c $Execute $Params

Write-Host "Exiting $Execute process..."

Start-Sleep -s 1

Write-host "Exit detected..."
Write-Host "Disconnecting from $ConnectionName..."
rasdial $ConnectionName /DISCONNECT
ipconfig /renew

 

 

 

powered by Icomments'