commit 37a11c2090343787221ac2a2f867ed5435f97473 Author: Eliezer Croitoru Date: Sat May 4 01:12:15 2024 +0300 1 diff --git a/conn-details.ps1 b/conn-details.ps1 new file mode 100644 index 0000000..c326122 --- /dev/null +++ b/conn-details.ps1 @@ -0,0 +1,44 @@ +$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