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

SBH

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
martin

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/*D.zip>=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.
SBH

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 D.zip 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 = "*D.zip>=1D|*/"

Any help would be greatly appreciated. Script file attached.