script creating local folder rather than using defined in script

  • I'm using this script as a template to be retrieving files from sftp site. Instead of using the defined in script local drive to send files it creates a new folder.

     

    It copied file too:

    d:\download\home\user

     

    Why?

     

    Thanks.

     

    try
    {
    # Load WinSCP .NET assembly
    Add-Type -Path "WinSCPnet.dll"

    # Setup session options
    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Sftp
    HostName = "example.com"
    UserName = "user"
    Password = "mypassword"
    SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..."
    }

    $session = New-Object WinSCP.Session

    try
    {
    # Connect
    $session.Open($sessionOptions)

    # Download files
    $transferOptions = New-Object WinSCP.TransferOptions
    $transferOptions.TransferMode = [WinSCP.TransferMode]::Binary

    $transferResult =
    $session.GetFiles("/home/user/*", "d:\download\", $False, $transferOptions)

    # Throw on any error
    $transferResult.Check()

    # Print results
    foreach ($transfer in $transferResult.Transfers)
    {
    Write-Host "Download of $($transfer.FileName) succeeded"
    }
    }
    finally
    {
    # Disconnect, clean up
    $session.Dispose()
    }

    exit 0
    }
    catch
    {
    Write-Host "Error: $($_.Exception.Message)"
    exit 1
    }
  • you are using a software for which thee vendor has a forum of its own - their forum is where you should be asking this question, not here, neither on a Powershell forum as the issue has nothing to do with Powershell.

  • Thanks did find answer on there site.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply