Topic "How can i get a Filelist like Get-Childitem"

Author Message
[View user's profile]

Joined: 2013-04-17
Posts: 1

we using Winscp .Net assembly to download Files from Ftp to a local Folder. Now sometimes it interrupt without any error. So my Files are not completed. So i will ad in my Windows Task a New Script. This Script should compare the Ftp-Folder with my local Folder. If not all Files from FTP in my local Folder, then win SCP should start sync again.

But i try the following without success, because the File List Remote cant be compare with the file List which i get with Get-Childitem from local Folder.

$rz_log = "C:\src\logs\RZ\RZ_log_Log_"+(get-date -format "yy-MM-dd")+".txt"
    # Load WinSCP .NET assembly
    # Use "winscp.dll" for the releases before the latest beta version.
    [Reflection.Assembly]::LoadFrom("C:\Program Files (x86)\WinSCP\WinSCP.dll") | Out-Null
    # Setup session options
    $sessionOptions = New-Object WinSCP.SessionOptions
    $sessionOptions.Protocol = [WinSCP.Protocol]::ftp
    $sessionOptions.HostName = "FTP-Server"
    $sessionOptions.UserName = "FTP-User"
    $sessionOptions.Password = "FTP-Pass"
    $session = New-Object WinSCP.Session

        # Connect
        $directory = $session.ListDirectory("/clara-17")
        Compare-Object -ReferenceObject  $(Get-ChildItem 'FolderLocal' -Recurse) -DifferenceObject  $directory  -Property Name
                foreach ($fileInfo in $directory.Files)
          Write-Host ("{0}" -f
        # Disconnect, clean up
    #exit 0
catch [Exception]
    Write-Host $_.Exception.Message
    exit 1

Can anybody give me an hint, how i can compare this two Folders?
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26911
Location: Prague, Czechia
Can you attach a log file for session, where it aborts without any error?
Martin Prikryl

You can post new topics in this forum


What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License