I'm guessing that is how it works. I'm adding some screenshots. I start the login with just my username then it prompts me for my password, it fails (at which point I receive the SMS), the GUI then provides another password box where I type in the verification code and login succeeds. Do you have any tips for translating this to the script or more specifically for trying to update the parameters of the session without starting a new one? I'm attaching my code below but my current approach is just calling
New-WinSCPSession
a second time and inputting the same username with a different password. It failed with a note that CAPTCHA is required. Once I logged in manually from the browser my script was able to logon. Any tips on resolving the CAPTCHA without the browser or not triggering it in the first place?
Thank you!
# Ask for credential, export to encrypted file, then import
$credential = Get-Credential
$credential | Export-Clixml ftpcredentials.xml
$ftpcredentials = Import-Clixml ftpcredentials.xml
New-WinSCPSession -SessionOption (New-WinSCPSessionOption -Credential $ftpcredentials -HostName "ftp.box.com" -Protocol Ftp) -SessionLogPath "C:\Users\patsm\Downloads\logfile.txt"
# ask for credentials again so user can input verification code as password
$credential = Get-Credential
$credential | Export-Clixml ftpcredentials.xml
$ftpcredentials = Import-Clixml ftpcredentials.xml
New-WinSCPSession -SessionOption (New-WinSCPSessionOption -Credential $ftpcredentials -HostName "ftp.box.com" -Protocol Ftp) -SessionLogPath "C:\Users\patsm\Downloads\logfile2.txt"