Connect to a VPN with Powershell

I want my Windows to connect to the VPN server immediately after it boots. How can I do this with Powershell?

+6
source share
3 answers

Try this with windows 10

$vpnName = "YOUR_VPN_NAME"; $vpn = Get-VpnConnection -Name $vpnName; if($vpn.ConnectionStatus -eq "Disconnected"){ rasdial $vpnName; } 
+3
source

You can try something like this:

I have not tested if it works. I have PowerShell V3 Beta installed - it may be necessary to run these commands.

 Register-ScheduledJob -name ConnectVPN -ScriptBlock { & rasphone MyVpnConnection $trigger = New-JobTrigger -AtLogOn Add-JobTrigger -Name ConnectVPN -Trigger $trigger Get-ScheduledJob -Name ConnectVPN | Get-JobTrigger 
+1
source

Among other answers, Windows 10 also supports this using the Always On configuration. More information about is always included at https://docs.microsoft.com/en-us/windows/access-protection/vpn/vpn-auto-trigger-profile

You can deploy either through MDM or even using WMI / Powershell

Deployment Links

VPN 2 CSP: https://docs.microsoft.com/en-us/windows/client-management/mdm/vpnv2-csp

CSP to WMI Bridge: https://docs.microsoft.com/en-us/windows/client-management/mdm/using-powershell-scripting-with-the-wmi-bridge-provider

+1
source

Source: https://habr.com/ru/post/915909/


All Articles