I am trying to automate the VPN connection through Openconnect.exe (given a password and TOTP) with a Windows PowerShell script. Unfortunately, I have not managed to supply the password to --passwd-on-stdin correctly, so I wondered, if a pro-user had been more successful. Thank you in advance for sharing your approach to this tedious task.
An update to the most recent version of openconnect, 9.12 at the time of writing, solved the issue. Get-Content pw.txt | openconnect https://target.url --user myname --passwd-on-stdin
now works as expected in PowerShell.