Keeping a connection open while running PowerShell commands
Hi all,
I'm creating automation where we download files from an SFTP, do various PowerShell commands on the data retrieved, wait 3 minutes and do the same thing again.
However, I want to be able to keep the connection to the server open indefinitely while I then query the SFTP every 3 minutes.
I want to achieve this by using a
I do not want to keep creating a connection/logging into the SFTP we have as I feel our firewall may pick this up as potentially unwanted behaviour.
My basic idea is
Apologies if this isn't clear enough
Is this possible?
I'm creating automation where we download files from an SFTP, do various PowerShell commands on the data retrieved, wait 3 minutes and do the same thing again.
However, I want to be able to keep the connection to the server open indefinitely while I then query the SFTP every 3 minutes.
I want to achieve this by using a
do
/while
loop in PowerShell that executes every 3 minutes.
I do not want to keep creating a connection/logging into the SFTP we have as I feel our firewall may pick this up as potentially unwanted behaviour.
My basic idea is
## 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"
Apologies if this isn't clear enough
Is this possible?
Last edited by ThomasHeaton on 2023-02-23 16:09; edited 1 time in total