45 lines
1.8 KiB
PowerShell
45 lines
1.8 KiB
PowerShell
|
$certUrl = "https://www.ngtech.co.il/cert-installer/kdumim/myCA.pem"
|
||
|
|
||
|
$urlDestFilename = "$env:Temp\cert.pem"
|
||
|
|
||
|
Invoke-WebRequest -Uri $certUrl -OutFile $urlDestFilename
|
||
|
|
||
|
powershell -Command "Import-Certificate -FilePath $urlDestFilename -CertStoreLocation Cert:\LocalMachine\Root"
|
||
|
|
||
|
Install-Module -Name VPNCredentialsHelper
|
||
|
|
||
|
Add-VpnConnection -Name "MySSTPVPN" -ServerAddress "k.ngtech.co.il:10443" -TunnelType "Sstp" -EncryptionLevel "Required" -AuthenticationMethod "MSChapv2" -RememberCredential
|
||
|
|
||
|
Set-VpnConnectionUsernamePassword -connectionname "MySSTPVPN" -username "test1" -password "test1234"
|
||
|
|
||
|
Set-VpnConnectionTriggerDnsConfiguration -ConnectionName "MySSTPVPN" -DnsSuffix "ngtech.home" -DnsIPAddress "192.168.74.1" -PassThru -Force
|
||
|
Set-VpnConnectionTriggerDnsConfiguration -ConnectionName "MySSTPVPN" -DnsIPAddress "192.168.74.1" -PassThru -Force
|
||
|
|
||
|
Set-VpnConnection -Name "MySSTPVPN" -SplitTunneling $true
|
||
|
|
||
|
Add-VpnConnectionRoute -ConnectionName "MySSTPVPN" -DestinationPrefix "192.168.74.0/24" -PassThru
|
||
|
Add-VpnConnectionRoute -ConnectionName "MySSTPVPN" -DestinationPrefix "192.168.109.0/24" -PassThru
|
||
|
Add-VpnConnectionRoute -ConnectionName "MySSTPVPN" -DestinationPrefix "192.168.206.0/24" -PassThru
|
||
|
Add-VpnConnectionRoute -ConnectionName "MySSTPVPN" -DestinationPrefix "192.168.220.0/24" -PassThru
|
||
|
|
||
|
(Get-VpnConnection -ConnectionName "MySSTPVPN").routes
|
||
|
|
||
|
$vpnName = "MySSTPVPN";
|
||
|
$vpnUsername = "test1"
|
||
|
$vpnPassword = "test1"
|
||
|
|
||
|
$vpn = Get-VpnConnection -Name $vpnName;
|
||
|
if($vpn.ConnectionStatus -eq "Disconnected"){
|
||
|
rasdial $vpnName $vpnUsername $vpnPassword;
|
||
|
}
|
||
|
|
||
|
$vpnName = "MySSTPVPN";
|
||
|
$vpn = Get-VpnConnection -Name $vpnName;
|
||
|
if($vpn.ConnectionStatus -eq "Connected"){
|
||
|
rasdial $vpnName /DISCONNECT;
|
||
|
}
|
||
|
|
||
|
Get-Vpnconnection | Select Name, Connectionstatus
|
||
|
|
||
|
Remove-VpnConnection -Name "MySSTPVPN" -Force -PassThru
|