SessionOptions Error

Advertisement

Guest

SessionOptions Error

I have a script that works in PowerShell using the WinSCP DLL it uploads a file and receive a receipt and I have copied out the relevant parts for another script using the same methodology.

I use variables with the relevant info and have ** out the ppk name
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::Sftp
        HostName = "$urlID"
        UserName = "$Username"
        Password = "$null"
        SshHostKeyFingerprint = "$certfp"
        SshPrivateKeyPath     = "C:\Users\user\.ssh\*******.ppk"
    }
And I get the following error
New-Object : The value supplied is not valid, or the property is read-only. Change the value, and then try again.
At line:1 char:19
+ $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
+                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [New-Object], Exception
    + FullyQualifiedErrorId : SetValueException,Microsoft.PowerShell.Commands.NewObjectCommand
Not that helpful.

The only difference between the "working" code and this is that I get a password=******* in the working one. From what I have been told we use SSH authentication using the fingerprint and the ppk so no password.

Where am I going wrong?

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum