Hi,
I have upload script that can upload file into a simple FTP. BUT now i need to upload file into an SFTP, where post number 22 has to be assigned. How to change the code to adapt this need? This is to mention i do not want to use any third-party tool. Any help
please?
-----------------------------------------------
$Ftp = "ftp://files.reuters.com"
# Create a FTPWebRequest object to handle the connection to the ftp server
$ftpRequest = [System.Net.FtpWebRequest]::create($Ftp)
$ftpRequest.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile
# Set the request's network credentials for an authenticated connection
$ftpRequest.Credentials =
New-Object System.Net.NetworkCredential($Username,$Password)
$ftpRequest.UseBinary = $true
$ftpRequest.UsePassive = $true
# Read the File for Upload
$FileContent = gc -en byte $FileToUpload
$ftpRequest.ContentLength = $FileContent.Length
# Get Stream Request by bytes
$targetFile = $ftpRequest.GetRequestStream()
$targetFile.Write($FileContent, 0, $FileContent.Length)
# Closing the file to complete the upload session
$targetFile.Close()
$targetFile.Dispose()