-
-
Save austinsonger/3a34f00f1bcb41e26576ba0003657677 to your computer and use it in GitHub Desktop.
VPN Setup script for windows powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set these to the correct values | |
$server_address = "vpn.example.com" | |
$connection_name = "VPN Connection" | |
$certificate_path = "certificate.p12" | |
$ca_cert_path = "strongswanCert.pem" | |
$password = ConvertTo-SecureString -String "P12 passphrase" -AsPlainText -Force | |
# Import machine cert | |
Import-PfxCertificate -FilePath $certificate_path -CertStoreLocation Cert:\LocalMachine\My\ -Password $password | |
# Import CA root | |
Import-Certificate -FilePath $ca_cert_path -CertStoreLocation Cert:\LocalMachine\Root\ | |
# Add VPN connection IKEv2 with machine cert | |
Add-VpnConnection -Name $connection_name -ServerAddress $server_address -TunnelType Ikev2 -EncryptionLevel Required -AuthenticationMethod MachineCertificate -AllUserConnection | |
# Add IPv6 default route (::/0 does not work) | |
Add-VpnConnectionRoute -ConnectionName $connection_name -DestinationPrefix ::/1 | |
Add-VpnConnectionRoute -ConnectionName $connection_name -DestinationPrefix 8000::/1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment