Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

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)


Topic review



One of my genius co-workers figured this out for me.
It seems that with prior versions of the .net assembly you could list your session options right after the new winscpsession. Adding -SessionOption fixed the issue. This had be stumped for hours.

$Winscp_session = New-WinSCPSession  -SessionOption $WinscpSession_opts   -ErrorAction stop

Credential parameter no longer works

I'm making a script that SFTPs a file, using a user name and ssh key for authentication. I'm following the same template as is currently operating on another server. My new script works on that server, but not on the server it actually needs to run on.

I've bolded the part that is tripping it up. Basically the new winscpsession doesn't seem to be able to take the credential parameter defined in winscpoptions.

This is the error I get when I try to run in Powershell:

New-WinSCPSession : A positional parameter cannot be found that accepts argument ''.
At C:\bsd\ACH_Upload\ACH_Upload.ps1:57 char:31

The difference is that the old server is running an older version of the .net assembly (for powershell) vs

$Winscp_creds = new-object System.Management.Automation.PSCredential -ArgumentList $username , (ConvertTo-SecureString -AsPlainText -Force -String "unused")
$WinscpSession_opts = New-WinSCPSessionOption -Credential $Winscp_creds  -SSHPrivateKeyPath $ssh_authentication_key  -ftpmode passive -hostname $server -protocol Sftp  -SshHostKeyFingerprint $fingerprint
$WinscpTransfer_opts = New-WinSCPTransferOption -TransferMode Binary
$Winscp_session = New-WinSCPSession $WinscpSession_opts   -ErrorAction stop