Re: Keeping a connection open while running PowerShell commands
Use WinSCP .NET assembly, instead of scripting.
See Using WinSCP .NET Assembly from PowerShell
See Using WinSCP .NET Assembly from PowerShell
do
/while
loop in PowerShell that executes every 3 minutes.
## Keep connection open [TESTING]
& "C:\Program Files (x86)\WinSCP\WinSCP.com" `
/log="FILEPATH" /ini=nul `
/command `
"open sftp://Name[IP]/ -hostkey=`"`"[Key]`"`" -privatekey=`"`"C:\TEST`"`"" `
"cd /Outbound" `
# Keep getting files every 3 minutes
DO WHILE
[ GET DATA ]
[ DO SOMETHING WITH DATA ]
FINALLY
"exit"