How us Ftp with the TSL protocol

Advertisement

Arenas
Joined:
Posts:
3
Location:
France

How us Ftp with the TSL protocol

Hello
Please,
I have never us WinScp
and how include the TSL 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)

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
31,060
Location:
Prague, Czechia

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?

Reply with quote

Arenas
Joined:
Posts:
3
Location:
France

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 run WinSCP to upload the update files

But WinSCP block te Task Manager
Please how do?
Thanks Arnold


martin wrote:

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

Reply with quote

Arenas
Joined:
Posts:
3
Location:
France

Re: How us Ftp with the TSL protocol

martin wrote:

To use implicit TLS/SSL, set SessionOptions.FtpSecure to FtpSecure.Implicit:
https://winscp.net/eng/docs/library_sessionoptions#ftpsecure

WinSCP GUI can generate a code template for you:
https://winscp.net/eng/docs/ui_generateurl#code
Hello
Thanks for your reply

The Sugestion is:
protocole ftpes with TLS explicite port 21 to upload files

With PowerShell:
cls
" 1"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls
Invoke-WebRequest "https://arenas.pagesperso-orange.fr/GradientExample/frameset-mediaplayer.html"
"=============================================="
" 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

Reply with quote

Advertisement

You can post new topics in this forum