Synchronizes directories with an active WinSCP Session.
Sync-WinSCPPath [-WinSCPSession] <Session> [[-Mode] <SynchronizationMode>] [[-LocalPath] <String>] [[-RemotePath] <String>] [-Remove] [-Mirror] [[-Criteria] <SynchronizationCriteria>] [[-TransferOptions] <TransferOptions>] [<CommonParameters>]
Synchronizes a local directory with a remote directory, or vise versa with an active remote host.
WinSCPSession <WinSCP.Session>
A valid open WinSCP Session, returned from New-WinSCPSession.
Mode <WinSCP.SynchronizationMode>
Possible values are SynchronizationMode.Local, SynchronizationMode.Remote and SynchronizationMode.Both.
Full path to local directory.
Full path to remote directory.
When used, synchronizes in mirror mode (synchronizes also older files). Cannot be used for -Mode Both.
Comparison criteria. Possible values are None, Time (default), .Size and Either. For -Mode Both Time can be used only.
TransferOptions <WinSCP.TransferOptions>
Defines options for file transfers.
CommonParameters <CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
If the WinSCPSession is piped into this command, the connection will be closed and the object will be disposed upon completion of the command.
PS C:\> New-WinSCPSession -Credential (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $env:USERNAME, (New-Object -TypeName System.Security.SecureString)) -HostName $env:COMPUTERNAME -Protocol Ftp | Sync-WinSCPDirectory -RemotePath '/' -LocalPath 'C:\lDir\' -Mode Local
Uploads : {}
Downloads : {/rDir/rSubDir/rFile.txt}
Removals : {}
Failures : {}
IsSuccess : True
PS C:\> $credential = Get-Credential
PS C:\> $session = New-WinSCPSession -Credential $credential -Hostname 'myftphost.org' -SshHostKeyFingerprint 'ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx'
PS C:\> Sync-WinSCPDirectory -WinSCPSession $session -RemotePath '/' -LocalPath 'C:\lDir\' -SyncMode Local
Uploads : {}
Downloads : {/rDir/rSubDir/rFile.txt}
Removals : {}
Failures : {}
IsSuccess : True