none
ftp синхронизация исключить папки RRS feed

  • Вопрос

  • cd "C:\Program Files (x86)\WinSCP"
    # Load WinSCP .NET assembly
    Add-Type -Path "WinSCPnet.dll"
    # Session.FileTransferred event handler
    while ($True){ 
    $telo = function FileTransferred
    {
        param($e)
     
        if ($e.Error -eq $Null)
        {
            Write-Host "Upload of $($e.FileName) succeeded"
        }
        else
        {
            Write-Host "Upload of $($e.FileName) failed: $($e.Error)"
        }
     
        if ($e.Chmod -ne $Null)
        {
            if ($e.Chmod.Error -eq $Null)
            {
                Write-Host "Permissions of $($e.Chmod.FileName) set to $($e.Chmod.FilePermissions)"
            }
            else
            {
                Write-Host "Setting permissions of $($e.Chmod.FileName) failed: $($e.Chmod.Error)"
            }
     
        }
        else
        {
            Write-Host "Permissions of $($e.Destination) kept with their defaults"
        }
     
        if ($e.Touch -ne $Null)
        {
            if ($e.Touch.Error -eq $Null)
            {
                Write-Host "Timestamp of $($e.Touch.FileName) set to $($e.Touch.LastWriteTime)"
            }
            else
            {
                Write-Host "Setting timestamp of $($e.Touch.FileName) failed: $($e.Touch.Error)"
            }
     
        }
        else
        {
            # This should never happen during "local to remote" synchronization
            Write-Host "Timestamp of $($e.Destination) kept with its default (current time)"
        }
    }
     
    # Main script
    
    # Setup session options
    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::Ftp
        HostName = "IP"
        UserName = "User"
        Password = "Password"
    }
    
        $session = New-Object WinSCP.Session
        try
        {
            # Will continuously report progress of synchronization
            $session.add_FileTransferred( { FileTransferred($_) } )
     
            # Connect
            $session.Open($sessionOptions)
     
            # Synchronize files
            $synchronizationResult = $session.SynchronizeDirectories(
                [WinSCP.SynchronizationMode]::Remote, "D:\update", "/ftp", $False)
            
            # Throw on any error
            $synchronizationResult.Check()
        }
        finally
        {
            # Disconnect, clean up
            $session.Dispose()
        }
    
    $telo
    if ($telo -eq $NULL){
    write-host "OK"
    Break
    }
    }

    Всем привет. Народ как исключить все папки при синхронизации с фтп, то есть на фтп будут загружены только файлы

    D:\update\papka\zp.zip > ftp/zp.zip

    • Изменено Pokesh 18 ноября 2021 г. 7:42
    18 ноября 2021 г. 7:37