Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: How us Ftp with the TSL protocol

Arenas wrote:

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.
Arenas

Re: How us Ftp with the TSL protocol

Hello
Thanks for your reply

The Suggestion is:
Protocol FTPES with TLS explicit port 21 to upload files.

With PowerShell:
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

Thanks
Arnold
Arenas

Re: How us Ftp with the TSL protocol

Hello @Martin
Thanks for your reply

Yes I want switch to WinSCP
In order I would do

  1. Run the the task manager (PowerShell files)
  2. Run WinSCP to upload the update files

But WinSCP block the Task Manager.
Please how do?
Thanks Arnold
martin

Re: How us Ftp with the TSL protocol

I'm not sure I understand your question.
Your code does not use WinSCP.
Do you want to switch to WinSCP?
Arenas

How use FTP with the TLS protocol

Hello
Please,
I have never used WinSCP
and how include the TLS protocol and run with WinSCP?
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls

Thanks for your help
Arnold

The script is:
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)