forked from adbertram/Random-PowerShell-Work
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |