Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

bdean@coherebeauty.com

Thanks

Thanks I had no idea it did that, I had the script working it .txt file... using the basic commands, I just wanted to automate all into a ps1.

I'll take at the GUI thanks very much!
bdean@coherebeauty.com

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 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"

Error logs:
(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

as you can see my " 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