Error with PowerShell and XML settings file for WinSCP Protocol setting
Hi everyone
I get this error:
settings.xml:
I get this error:
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 theThe value supplied is not valid, or the property is read-only. Change the value, and then try again.
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
<?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>