简体   繁体   中英

Creating a VPN connection in PowerShell

I'm using the following PowerShell command to create VPN Connection for the native Windows VPN client

Add-VpnConnection -Name "VPN" -ServerAddress "vpn.randomdomain.com" -TunnelType L2TP -L2tpPsk "SuperSecurePassword" -Force -AuthenticationMethod MSChapv2 -SplitTunneling $True -EncryptionLevel "Optional"

And it works perfectly! However, I'd like for the "Automatically use my Windows logon name and password" (and domain, if any) Checkbox (Under MS-CHAP v2) to be checked as well. How do I add that to my command ?

I found how myself, add -UseWinlogonCredential after MSChapv2

simple enough!!

Example

Add-VpnConnection -Name "VPN" -ServerAddress "vpn.randomdoman.com" -TunnelType L2TP -L2tpPsk "SuperSecurePassword" -Force -AuthenticationMethod MSChapv2 -UseWinlogonCredential -SplitTunneling $True -EncryptionLevel "Optional"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM