Fingerprint SFTP connection variable assigned PowerShell

Advertisement

Madeproel
Guest

Fingerprint SFTP connection variable assigned PowerShell

Hello,

I have a PowerShell script in which the credentials are set dynamically via variables. For hostname, username, password this works. But not for the fingerprint. I always get the following message:
New-Object : The specified value is invalid, or the property is read-only. Change the value and repeat the operation.
Here is an excerpt of my script. The values was replaced by "xxxx".
function getCreds(){
    $creds=[PSCustomObject]@{
        hostname = ''
        username = ''
        pwd = ''
        fingerprint = ''   
    }
    $creds.hostname = 'xxxx'
    $creds.username = 'xxxx'
    $creds.pwd = 'xxxx'
    $creds.fingerprint = 'ssh-rsa 1024 xxxx'
    return $creds
}
 
function transferFile($creds){
    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::Sftp
        HostName = $creds.hostname
        UserName = $creds.username
        Password = $creds.pwd
        SshHostKeyFingerprint = $creds.fingerprint
    }
}
$creds=getCreds()
transferFile($creds)

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum