Arnold asked this 2 weeks ago

Cryptage TLS/SSL explicite

Hello

Pls, how transform my scripte to us as :

Cryptage TLS/SSL explicite
normal
passive

This script at now works, to upload files, perfect.

 

Thanks for your help

@r

 

The scripte:

You have to adapte your folder-name

$Xa = (Get-Host).UI.RawUI
$Xa.WindowTitle = "Sync Folder To Ftp"

$Xftp = "ftp://........../if folder-name ??/"
$Xuser = "......."
$Xpass = "......."

$XlocalDirectory = Get-Content "c:\folder-name"

$Xwebclient = New-Object System.Net.WebClient
$Xwebclient.Credentials = New-Object System.Net.NetworkCredential($Xuser,$Xpass) 
$XFiles = Get-ChildItem -Path "c:\folder-name ??\*" -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:\folder-name ??\","")
     $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
""

clear-variable X* -scope global -F


Jake 2 weeks ago

webclient does not support TLS/SSL, you will have to use FtpWebRequest instead.