PoshCode Archive  Artifact [512e146876]

Artifact 512e1468766096f87e19f3d4fd6dccc97367fbad00e144bb20d56914bccb2277:

  • File Connect-ToIpsecVpn.ps1 — part of check-in [303d53c441] at 2018-06-10 13:45:02 on branch trunk — This script uses the Cisco IPSEC VPN client to connect to a VPN gateway and immediately RDP to a device. (user: Adam Bertram size: 1077)

# 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