Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $vpnName = "YourVpnName"
- $vpnServerAddress = "YourVpnServerAddress"
- $vpnUserName = "YourVpnUserName"
- $vpnPassword = "YourVpnPassword"
- $vpn = Get-VpnConnection -Name $vpnName
- if($vpn -eq $null) {
- Add-VpnConnection -Name $vpnName -ServerAddress $vpnServerAddress -TunnelType Pptp -EncryptionLevel Required -PassThru
- echo "vpn created"
- }
- if($vpn.ConnectionStatus -eq "Disconnected"){
- $cmd = $env:WINDIR + "\System32\rasdial.exe"
- $expression = "$cmd ""$vpnName"" $vpnUserName $vpnPassword"
- Invoke-Expression -Command $expression
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement