From edb0924fbc4295d43b6967d5d9ebc74434910b9b Mon Sep 17 00:00:00 2001 From: Adam Bertram Date: Sun, 30 Jun 2019 09:15:35 -0500 Subject: [PATCH] Create connect-vpn.ps1 --- Networking/connect-vpn.ps1 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Networking/connect-vpn.ps1 diff --git a/Networking/connect-vpn.ps1 b/Networking/connect-vpn.ps1 new file mode 100644 index 0000000..1aee2d6 --- /dev/null +++ b/Networking/connect-vpn.ps1 @@ -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