Error with powershell and xml settings file for WINSCP Protocol setting

Advertisement

adamardaa
Guest

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, its just the Protocol. I've tried all four combinations of "" around the value. Any ideas ? Huge thanks. Adam
=======powershell==========================================================================
try
{
# 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>

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,685
Location:
Prague, Czechia

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".

Reply with quote

adamb-
Joined:
Posts:
1
Location:
UK

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

martin wrote:

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

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

Reply with quote

Guest

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

adamb- wrote:

martin wrote:

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

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

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 recieved

Adam

Reply with quote

Guest

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

Anonymous wrote:

adamb- wrote:

martin wrote:

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

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

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 recieved

Adam

Reply with quote

Advertisement

Guest

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

Anonymous wrote:

Anonymous wrote:

adamb- wrote:

martin wrote:

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

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

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 recieved

Adam

All fixed now I was using #tlshostcertificatefingerprint instead of SshHostKeyFingerprint in the session options
All fixed - Thanks for reading

Adam

Reply with quote

Advertisement

You can post new topics in this forum