A powershell script that auto connects a Cisco Anyconnect VPN with and without defender token
This is a powershell script that I wrote to automatically login into cisco Anyconnect VPN both using defender token as well as without it. Note that this script was written with only defender token in mind. If you need to use cisco anyconnect VPN client with another type of token, this script needs to be modified accordingly. The script is pretty straight forward and is easy to setup and run. Please look at the setup instructions below.
- You need to have powershell installed and you need a minimum of version 2.0.
- You need to have .Net framework installed
- You need to have atleast powershell version 5.0 installed if you intend to use this script with defender token.
- This script was tested agianst cisco anyconnect version 3.1.
- This script was tested using one identity defender soft token for windows with version 5.9.1
- Clone or download the file AnyConnectAutoConnect.ps1
- Fill the path for vpncliAbsolutePath, vpnuiAbsolutePath and defendertokenfilepath
- If you call the program with the VPN URL, username and password it will connect automatically without taking defender token into account
- IF you need the script to work with one identity Defender token, you need to call the script with VPN URL, username, password and password for defender token.
- To connect without using defender token, you can create a .bat file with the following command
powershell ". .\AnyConnectAutoConnect.ps1; VPNConnect -vpnaddress \"{your VPN Address here}\" -user \"{your username}\" -pass \"{Your password}\""- To connect using defender token, you can create a .bat file with the following command
powershell ". .\AnyConnectAutoConnect.ps1; VPNConnect -vpnaddress \"{your VPN Address here}\" -user \"{your username}\" -pass \"{Your password}\" -defenderpass \"{your defender password}\""