Advertisement
garfield

Untitled

Nov 11th, 2023
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. $vpnName = "YourVpnName"
  2. $vpnServerAddress = "YourVpnServerAddress"
  3. $vpnUserName = "YourVpnUserName"
  4. $vpnPassword = "YourVpnPassword"
  5. $vpn = Get-VpnConnection -Name $vpnName
  6. if($vpn -eq $null) {
  7. Add-VpnConnection -Name $vpnName -ServerAddress $vpnServerAddress -TunnelType Pptp -EncryptionLevel Required -PassThru
  8. echo "vpn created"
  9. }
  10.  
  11. if($vpn.ConnectionStatus -eq "Disconnected"){
  12. $cmd = $env:WINDIR + "\System32\rasdial.exe"
  13. $expression = "$cmd ""$vpnName"" $vpnUserName $vpnPassword"
  14. Invoke-Expression -Command $expression
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement