I try with this script, but it didn't work for me
$file = "test.txt"
$filePath = "C:\" + $file
$server = "ftp://server"
IF (Test-Connection -ComputerName $server -Quiet -Count 1 -ErrorAction SilentlyContinue)
{
$ftp = $server+$file
$webclient = New-Object System.Net.WebClient
$uri = New-Object System.Uri($ftp)
"Uploading $File..."
$webclient.UploadFile($uri, $filePath)
}
ELSE
{write-host "error"}
when I run the script , I have message "error" in the host it's mean there isn't contact with the server ,but when I ping the server is respond