Post a reply

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

Guest

Re: Error with powershell and xml settings file for WINSCP Protocol setting

All fixed now. I was using TlsHostCertificateFingerprint instead of SshHostKeyFingerprint in the session options.
All fixed – Thanks for reading.

Adam
Guest

Re: Error with powershell and xml settings file for WINSCP Protocol setting

But now I have the same problem with the TlsHostCertificateFingerprint, this time even when I hardcode the string PowerShell rejects it with the same error message:
Error: The value supplied is not valid, or the property is read-only. Change the value, and then try again.

Any help very gratefully received
Adam
adamb-

Re: Error with powershell and xml settings file for WINSCP Protocol setting

Hi Martin, how simple, that worked thank you! Now to get it working with sftp.
martin

Re: Error with powershell and xml settings file for WINSCP Protocol setting

PowerShell won't convert string "[WinSCP.Protocol]::ftp" to enumeration value [WinSCP.Protocol]::Ftp. But it will convert simple "ftp".
adamardaa

Error with PowerShell and XML settings file for WinSCP Protocol setting

Hi everyone
I get this error:
The value supplied is not valid, or the property is read-only. Change the value, and then try again.

If I hard code the value it works fine. I've checked the value is being pulled from the xml file by doing a write-output and it's fine. The other values work fine, it's just the Protocol. I've tried all four combinations of "" around the value. Any ideas? Huge thanks. Adam
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    #Protocol = "[WinSCP.Protocol]::Ftp"
    Protocol = $configfile.settings.FTPServerSettings.protocol
    HostName = $configfile.settings.FTPServerSettings.hostname
    PortNumber = $configfile.settings.FTPServerSettings.portnumber
    UserName = $configfile.settings.FTPServerSettings.username
    Password = $configfile.settings.FTPServerSettings.password
}
 
$session = New-Object WinSCP.Session

settings.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- setting file for use with WinSCP -->
<settings>
   <FileSettings>
      <LogFile>E:\WinSCP\Bentley</LogFile>
   </FileSettings>
   <FTPServerSettings>
      <protocol>[WinSCP.Protocol]::ftp</protocol>
      <hostname>ftp.blahblah.co.uk</hostname>
      <portnumber>21</portnumber>
      <username>blahblahblah</username>
      <password>blah</password>
      <ftpsecure></ftpsecure>
      <tlshostcertificatefingerprint></tlshostcertificatefingerprint>
   </FTPServerSettings>
<!--   <FileDownload>
      <remotePath>/OUT/*</remotepath>
      <localPath>C:\Temp\</localpath>
   </FileDownload>
   <FileUpload>
      <localpath>C:\Temp\*"</localpath>
      <remotepath>/IN/</remotepath>
   </FileUpload> -->
</settings>