Skip to content

Commit

Permalink
Create connect-vpn.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
adbertram authored Jun 30, 2019
1 parent 8cb9d33 commit edb0924
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Networking/connect-vpn.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## One Time only. This is to securely store your VPN password to an encrypted text file
Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File encrypted_password.txt

## The VPN profile name configured in your client
$vpn_profile = 'Profile name'
$username = 'username'

## Decrypt the password
$enc_password = (gc .\encrypted_password.txt | ConvertTo-SecureString)

## Create the credentials
$credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$enc_password $password = $credentials.GetNetworkCredential().Password

## Pass the appropriate arguments to the VPN client EXE
Set-Location 'C:\Program Files (x86)\Cisco Systems\VPN Client'
.\vpnclient.exe connect $vpn_profile user $username pwd $password

## Use this if you have a need to disconnect via script
#Set-Location 'C:\Program Files (x86)\Cisco Systems\VPN Client'
#.\vpnclient.exe disconnect

## RDP to a device. mstsc /v:HOSTNAME /multimon

0 comments on commit edb0924

Please sign in to comment.