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:
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:
Here is an excerpt of my script. The values was replaced by "xxxx".New-Object : The specified value is invalid, or the property is read-only. Change the value and repeat the operation.
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)