Skip to content

Instantly share code, notes, and snippets.

@davejlong
Created July 12, 2019 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davejlong/1e242e2543aa6f4e51c63f9bd89090aa to your computer and use it in GitHub Desktop.
Save davejlong/1e242e2543aa6f4e51c63f9bd89090aa to your computer and use it in GitHub Desktop.
Creates a new L2TP VPN Connection (written for Atera RMM)
###
# Author: Dave Long <dlong@cagedata.com>
# Created: 2019-07-12
# Last Modified: 2019-07-12 # Create function
#
# Creates a VPN connection for connecting to an L2TP VPN server
###
function Add-L2TPVpnConnection {
param(
[string]$Name,
[string]$ServerAddress,
[string]$Psk
)
# Don't try to recreate the same VPN again.
if (Get-VPNConnection | Where-Object Name -eq $Name) { return $true }
Add-VpnConnection -Name $Name -ServerAddress $ServerAddress -TunnelType L2tp -L2tpPsk $Psk -EncryptionLevel Required -AuthenticationMethod MSChapv2 -RememberCredential -AllUserConnection -Force
}
Add-L2TPVpnConnection -Name "{[ConnectionName]}" -ServerAddress "{[ServerAddress]}" -Psk "{[PreSharedKey]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment