Windows Powershell Script Help - Slight Tweak

This topic contains 7 replies, has 3 voices, and was last updated by  veer 3 months, 2 weeks ago.

  • Author
    Posts
  • #73207

    Anonymous

    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!

  • #73226

    Dirk
    Participant

    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)
    }
  • #73274

    Anonymous

    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

  • #73339

    Dirk
    Participant

    Hi,

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

  • #73490

    Anonymous

    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.

  • #73564

    Anonymous

    Any help would be greatly appreciated.

    Thanks so much.

  • #73573

    Dirk
    Participant

    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\')
    
  • #76591

    veer
    Participant

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

You must be logged in to reply to this topic.