# encoding: ascii
# api: powershell
# title: Connect-ToIpsecVpn
# description: This script uses the Cisco IPSEC VPN client to connect to a VPN gateway and immediately RDP to a device.
# version: 0.1
# author: Adam Bertram
# license: CC0
# x-poshcode-id: 4721
# x-archived: 2013-12-22T06:36:42
# x-published: 2013-12-19T14:28:00
#
#
## One Time only to create the password file
Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File encrypted_password.txt
$vpn_profile = 'Profile name'
$username = 'username'
$enc_password = (gc .\encrypted_password.txt | ConvertTo-SecureString)
$credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$enc_password
$password = $credentials.GetNetworkCredential().Password
Set-Location 'c:\Program Files (x86)\Cisco Systems\VPN Client'
.\vpnclient.exe connect $vpn_profile user $username pwd $password
## Disconnect
#Set-Location 'c:\Program Files (x86)\Cisco Systems\VPN Client'
#.\vpnclient.exe disconnect
## RDP to a device
mstsc /v:HOSTNAME /multimon