Skrypt dodający VPN dla wszystkich użytkowników, automatycznie wykorzystujący poświadczenia bieżącego użytkownika.
PowerShell
#
# Adds VPN SSTP connection with Windows SSO enabled.
#
$name = "Example VPN"
$serverAddress = "vpn.example.com"
$dnsSuffix = "example.wew"
$vpn = Get-VpnConnection -AllUserConnection -Name $name
if (!$vpn) {
Add-VpnConnection -AllUserConnection `
-Name $name `
-ServerAddress $serverAddress `
-TunnelType "Sstp" `
-DnsSuffix $dnsSuffix `
-AuthenticationMethod "MSChapv2" `
-EncryptionLevel "Maximum" `
-RememberCredential `
-IdleDisconnectSeconds 3600
# Doesn't work with WHfB
#-UseWinlogonCredential
$vpn = Get-VpnConnection -AllUserConnection -Name $name
if ($vpn) {
Write-Verbose "VPN connection created."
}
else {
Write-Error "Failed to create VPN connection!"
}
}
else {
Write-Verbose "VPN connection already exists. Skipping..."
}