Post a reply

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)


Topic review


Thank you

Thanks Martin, that's fixed the issue. Setting the file mask in the remote directory variable stops the lack of permissions to the sub directories causing the problem.

Many Thanks

Re: Script to download files non-recursively - failing permission denied

Your code looks OK to me, except that $remotePath should probably be "/XML/*". Or even "/XML/*>=1D" straight away (and you won't need the TransferOptions).

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Script to download files non-recursively - failing permission denied

Hi, I'm trying to download files from an Sftp site with a basic power shell script based on the excellent one from here. I'm trying to download files ending with created in the last day from the root of the XML directory. The files are only from the root as the ID I'm using to access the directory doesn't have permissions to the sub directories. However when the script runs it doesn't download anything as it fails with the error below. The directory 1000 is one the ID has no permission too.

Error listing directory '/XML/1000'.
Permission denied.
Error code: 3

Error message from server (en): Permission denied.

The file mask I'm trying is FileMask = "*>=1D|*/"

Any help would be greatly appreciated. Script file attached.