Re: How us Ftp with the TSL protocol
The Sugestion is:
Protocol FTPES with TLS explicit port 21 to upload files
OK, I do not know why I've though that you asked for implicit.
So use
FtpSecure.Explicit
.
The Sugestion is:
Protocol FTPES with TLS explicit port 21 to upload files
FtpSecure.Explicit
.
cls
" 1"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls
Invoke-WebRequest "https://example.com/"
"=============================================="
" 2"
[Net.SecurityProtocolType]
" =============================================="
" 3"
# get TSL !!!
[enum]::GetNames([Net.SecurityProtocolType])
" =============================================="
" 4"
# Force PowerShell to use TLS 1.1
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls11
# ???
" ================================================= "
" 5"
# Force PowerShell to use it's default of TLS 1.0
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls
SessionOptions.FtpSecure
to FtpSecure.Implicit
:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls
cls
$Xa = (Get-Host).UI.RawUI
$Xa.WindowTitle = "Sync Folder To Ftp"
$Xftp = "ftp://perso-ftp.orange.fr/"
# $Xftp.UsePassive = $true
# $Xftp.EnableTls = $true
$XlocalDirectory = Get-Content "c:\studio\"
$Xuser = "............."
$Xpass = "............."
$Xwebclient = New-Object System.Net.WebClient
$Xwebclient.Credentials = New-Object System.Net.NetworkCredential($Xuser,$Xpass)
$XFiles = Get-ChildItem -Path "c:\studio\*" -Rec -For | ? {$_.LastWriteTime -gt (Get-Date).AddHours(-1)} | where { ! $_.PSIsContainer } | Select-Object FullName
$Xnombre = $XFiles.Count
foreach ($XFile in $XFiles)
{
$XLocalFile = $XFile.FullName
$XRemoveDirectory = $XLocalFile.Replace("C:\studio\","")
$XChangeSlashes = $XRemoveDirectory.Replace('\','/')
$XRemoveSpaces = $XChangeSlashes.Trim()
$XRemoteFile = $Xftp+$XRemoveSpaces
$Xuri = New-Object System.Uri("$XRemoteFile")
$Xwebclient.UploadFile($Xuri, $XLocalFile)
Write-Host "Getting $XFile from $XlocalDirectory" -Foreground "Red" -BackgroundColor DarkBlue
Write-Host "Puting $XFile to $Xftp" -Foreground "Yellow" -BackgroundColor DarkBlue
}
""
Write-Host "Finished Sync to $Xftp" -Foreground "Green" -BackgroundColor DarkBlue
""
$Xnombre.ToString() + " File sync -- END -- " + (Get-Date)
$Xtext1 = $Xnombre.tostring() + " File sync -- END -- " + (Get-Date)