#PowerShell Script Windows IKEv2 VPN EHB_DTSTUDENTS ################################ # VARIABLES $Name = "vpn.student.ehb.be" $ServerAddress = "vpn.student.ehb.be" $TunnelType = "IKEv2" $AuthenticationMethod = "EAP" $EncryptionLevel = "Maximum" $SplitTunneling = $true $DnsSuffix = "ehb.local" ################################ write-host -nonewline $Name" will be installed. Continue? (Y/N) " $response = read-host If(-not($response)){$response = "Y"} if ( $response -ne "Y") { exit } #Check if VPN EHB_DTSTUDENTS is installed if ((Get-VpnConnection -Name $Name -ErrorAction SilentlyContinue) -Or (Get-VpnConnection -AllUserConnection -Name $Name -ErrorAction SilentlyContinue)) { Write-Host $Name" does already exist" pause } # Else, create VPN connection else { #Disconnect VPN Get-VpnConnection -AllUserConnection | Where-Object {$_.ConnectionStatus -eq "Connected"} |Rasdial.exe /disconnect Get-VpnConnection | Where-Object {$_.ConnectionStatus -eq "Connected"} #Remove old VPN #Get-VpnConnection |Remove-VpnConnection -Force #Install IKEv2 VPN Add-VpnConnection -Name $Name -ServerAddress $ServerAddress -TunnelType $TunnelType -EncryptionLevel $EncryptionLevel -DnsSuffix $DnsSuffix -AuthenticationMethod $AuthenticationMethod -Force Set-VpnConnection -Name $Name -SplitTunneling $SplitTunneling -ForceĀ  pause }