Hi, I am trying to trouble a winscp connection script I didn’t write. The below code logs in and tries download some files matching a parsed date but I simply get an error because there is no test or catch condition in place to confirm a connection has actually been established.<\/p>\n
I know the connection does work as have used Filezilla to connect and get my files but I need automate it with Powershell and this previously working code is now erring but only gives me exit result “Error”<\/p>\n
I simply want to check that the connection is actually established and if not report no connection established. I’ve tried various snippets to perform a connx test but I’m doing something wrong.<\/p>\n
The full (obfuscated) script is provided as I have tried putting in a catch clause etc and have failed miserably, probably because how I formatted it amongst existing script as it already has a try command in it and I’m probably nesting completely wrong…<\/p>\n You have a Try block, but I don’t see a Catch block to handle any errors.<\/p>\n<\/code>","upvoteCount":3,"answerCount":4,"datePublished":"2022-01-13T14:57:29.000Z","author":{"@type":"Person","name":"spiceuser-y9o2u","url":"https://community.spiceworks.com/u/spiceuser-y9o2u"},"acceptedAnswer":{"@type":"Answer","text":"