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

martin

Re: Remove files from Remote server

Please read my previous post again carefully.
The Session.GetFiles can remove the downloaded files for you. Just pass $True to the remove parameter.
dlh161

Remove files from Remote server

Hi,

Thanks for the response. The $session.GetFiles works as expected. It is the $session.RemoveFiles command that I am having trouble with. Once I download the PDF files, I would like to remove the PDF files from the remote location. Only the remote PDF files.
martin

Re: Remove files from Remote server

Your code seems to be correct syntactically. I cannot imagine that you are getting the error you have posted with the code you have posted. Please double check that you are running the right code.
In any case, the right solution is to pass $True to the remove parameter of Session.GetFiles:
$session.GetFiles("/Home/folder/files.pdf", "D:\daily files", $True, $transferOptions).Check()

See https://winscp.net/eng/docs/library_session_getfiles
dlh161

Remove files from Remote server

Hello,

I am trying to remove files from a remote server after I have downloaded them to my local server. I found some code from the forum. The commands I am using are the following:
$session.GetFiles("/Home/folder/files.pdf", "D:\daily files", $False, $transferOptions).Check()
$session.RemoveFiles("/Home/folder/files.pdf")

When trying this, I am receiving an error.
Cannot find an overload for "RemoveFiles" and the argument count: "3"

What is the syntax of the command I should be using? I only want to remove the pdf files in this folder.
Thank you