Windows Powershell Script Help - Slight Tweak

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!

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)
}

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

Hi,

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

Hello,

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

https://www.screencast.com/t/bCEoTBXJP4f4

I look forward to your response.

Any help would be greatly appreciated.

Thanks so much.

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\')

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