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.

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

arichins

solved

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
arichins

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 'ozk1g2ty@safetransvalidate.wellsfargo.com'.
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) 5.17.5.3 vs 5.14.4.0.

$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