Author Posts

June 19, 2017 at 4:42 pm

Hello,

I would be grateful if someone could help me with my issue. I have got a powershell script which downloads files from a SFTP folder into a local folder on my computer and then the file is deleted. It works fine. However, I want it to download into two local folders and then for the file to be deleted. Can anyone please assist me with this. Here is the current code below, just want to add an additional local path:

***Removed code at the request of the user.*** – WA

Thanks in advance!

June 19, 2017 at 8:06 pm

Hi,

this should do the trick (just pasting the relevant parts):

$localPaths = 'c:\folder1\', 'c:\folder2\'
# Synchronize files to local directory, collect results
foreach ($localPath in $localPaths){
    $synchronizationResult = $session.SynchronizeDirectories(
    [WinSCP.SynchronizationMode]::Local, $localPath, $remotePath, $False)
}

June 20, 2017 at 1:06 pm

Hello,

Thanks so much for your response, I am very grateful for this. However, it does not work. This is the code I amended it too, please help. This is the image of the error:

Removed code at OPs request – WA

June 21, 2017 at 5:49 am

Hi,

I don't see the error message. Without it, it's pretty hard to tell what is wrong.

June 22, 2017 at 3:58 pm

Hello,

Thanks for your response, apologies I never saw it. Let me try again, see link below for screenshot:

2017-06-22_1656

I look forward to your response.

June 23, 2017 at 10:41 am

Any help would be greatly appreciated.

Thanks so much.

June 23, 2017 at 1:12 pm

Ok, you'll need to put the paths into parenthesis, since it is used as an argument for a parameter in your script:

$localPaths = ('c:\folder1\', 'c:\folder2\')

August 3, 2017 at 3:56 pm

Moderator can this thread please be removed as a matter of urgency, the first post contains some personal information.