Having trouble passing the correct commands to WinSCP from a PowerShell script, it's " and `'s that
Is my issue, I had the one working, and somehow seem to have broken both of them.
I connect to one server and download and a function then unzip and moves files around then another call to WinSCP is made to connect to another server and upload a file.
Pretty simple and it works fine from my
PS Shell snip:
Error logs:
(just relevant snippets)
as you can see my
Any help would be greatly appreciated.
Thanks -B
I connect to one server and download and a function then unzip and moves files around then another call to WinSCP is made to connect to another server and upload a file.
Pretty simple and it works fine from my
winscp.txt
scripts, however trying to add everything into PowerShell script which I will be calling from the Task Scheduler. So here's brief and the error logs from tkg_winscp.log
.
PS Shell snip:
& 'C:\Program Files (x86)\WinSCP\WinSCP.exe' /log="C:\scripts\logs\TKG_WinSCP.log" /ini=nul /command ` "option batch abort" ` "option confirm off" ` "option transfer binary" ` "open sftp://username:password@files.server.com -hostkey=`""ssh-rsa 4096 xxxxxxxxxxxxxxxxxxxxxxxxxxx""" ` "get /fromagency/*.zip E:\dataroot\$date\" ` "exit"
(just relevant snippets)
3:41:46.329 Command-line: "C:\Program Files (x86)\WinSCP\WinSCP.exe" /log=C:\scripts\logs\TKG_WinSCP.log /ini=nul /command "option batch abort" "option confirm off" "option transfer binary" "open sftp://username:***@files.server.com -hostkey="" ssh-rsa 4096 xxxxxxxxxxxxxxxxxxxxxxxxxxxx" "get /dir/*.zip E:\data\07262024\" exit 10 or so lines down, Script: open sftp://username:***@files.server.com -hostkey=" ssh-rsa 4096 XXXXXxxxxxxxxxxxxXXXXXXXXXX
"
and double "
and `
's are off as it is passed over to WinSCP to process with hostkey=" <space>
then no closing "
.
Any help would be greatly appreciated.
Thanks -B