Error connexion : Connecting to FTP error
It's work, i exclude it
SessionOptions.FtpSecure
:
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::ftp
HostName = "eportal-scheduled.services.xxxx.com"
UserName = "eportal-ftp@anonyme.fr"
Password = "xxxxxxxx*B"
FtpSecure = [WinSCP.FtpSecure]::Explicit
}
SessionOptions.TlsHostCertificateFingerprint
.
# Specify directories
$localPath = "C:\Temp\script"
$remotePath = "/test"
# Load WinSCP .NET assembly
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
try
{
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::ftp
HostName = "eportal-scheduled.services.xxxx.com"
UserName = "eportal-ftp@anonyme.fr"
Password = "xxxxxxxx*B"
}
$session = New-Object WinSCP.Session
try
{
# Connect
Write-Host "Connecting to FTP..."
$session.Open($sessionOptions)
# Download files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
Write-Host "Synchronizing changes..."
$transferResult =
$session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::Local, $localPath, $remotePath, $false. $transferOptions)
# Throw on any error
$transferResult.Check()
# Print results
foreach ($transfer in $transferResult.Downloads)
{
Write-Host "Download of $($transfer.FileName) succeeded"
}
}
finally
{
# Disconnect, clean up
$session.Dispose()
}
exit 0
}
catch
{
Write-Host "Error: $($_.Exception.Message)"
exit 1
}
Connecting to FTP...
Error: Exception calling "Open" with "1" argument(s): "Connection failed.
Connection failed.
Sorry, cleartext sessions are not accepted on this server.
Please reconnect using SSL/TLS security mechanisms."