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

martin

Re: Too many parameters for option option

If you want to provide commands on command-line, you have to quote individual commands and pass them as a single line.
Like $WinSCParg = @""open ""$FTPurl"" -explicit -certificate=""$FTPcert""" "option batch abort" "option confirm off" ..."@ (not tested)
See https://winscp.net/eng/docs/commandline#scripting

Your finding from your second post does not make any sense.

Anyway, you better use WinSCP .NET assembly:
https://winscp.net/eng/docs/library_powershell
Franzi

a little Update:
I found out, that writing the script-string into a file and instantly re-reading it into another string and deleting the file again solves the problem. So WinSCP doesn't like something about the first string. Does anybody have an idea why it won't accept the string?
Franzi

Too many parameters for option option

Hi,
Im currently scripting a backupscript in Powershell. Unfortunately I get the error "Too many parameters for option option". Going through the forum it often was an outdated WinSCP-version or simple misspelling or wrong characters. I can't see any of that in my case though, maybe you can see?

Here's my script:
$BackupSource= "D:\Data\stuffandthings\"


$FTPserver   = "123.456.789.012"
$FTPport     = "21"
$FTPuser     = "Username"
$FTPpassFile = "credentials.txt"
$FTPpass     = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR((Get-Content $File | ConvertTo-SecureString)))
$FTPcert     = "12:12:12:12:aa:aa:aa:aa:bb:bb:bb:bb:22:22:22:33:33:33:22:11"
$FTPurl      = "ftps://"+$FTPuser+":"+$FTPpass+"@"+$FTPserver+":"+$FTPport

$WinSCP  = "WinSCP.com" #path to WinSCP.com
$WinSCParg = @"
open "$FTPurl" -explicit -certificate="$FTPcert"
option batch abort
option confirm off
synchronize remote "$BackupSource" "/" -delete -resumesupport=on -preservetime -criteria=either
close
"@ #> "script.txt"

& $WinSCP -command $WinSCParg >> $LogFileCurrent
#& $WinSCP -script="script.txt" >> $LogFileCurrent
#del "script.txt"

as you can see in the end of the script I experimented with using a scriptfile, which once uncommented works just fine, like this:
[...]

$WinSCP  = "WinSCP.com" #path to WinSCP.com
$WinSCParg = @"
open "$FTPurl" -explicit -certificate="$FTPcert"
option batch abort
option confirm off
synchronize remote "$BackupSource" "/" -delete -resumesupport=on -preservetime -criteria=either
close
"@ > "script.txt"

& $WinSCP -script="script.txt" >> $LogFileCurrent
del "script.txt"


unfortunately if I write my password into this scriptfile in plaintext all my effort of scripting this leads to a security issue, which I don't want.
Does anybody see my error?