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?