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
Hello Thnx for your reply
the scripte is not work….
You have any idee?
thanks
Arnold
cls
$username = "…..."
$password = "...…."
$sendpath = "C:\studio\"
$sourceuri = "ftp://"
# Create an FTPWebRequest object to handle the connection to the FTP server
$ftprequest = [System.Net.FtpWebRequest]::Create($sourceuri)
# Set the request's network credentials for an authenticated connection
$ftprequest.Credentials = New-Object System.Net.NetworkCredential($username,$password)
# Set FTPWebRequest method to ListDirectory
$ftprequest.Method = [System.Net.WebRequestMethods+Ftp]::ListDirectory
$ftprequest.EnableSsl = $True
$ftprequest.UseBinary = $False
$ftprequest.UsePassive = $True
$ftprequest.KeepAlive = $False
$ftpresponse = $ftprequest.GetResponse()
Write-Out $ftpresponse.StatusCode
Write-Out $ftpresponse.StatusDescription
webclient does not support TLS/SSL, you will have to use FtpWebRequest instead.