I am new to Powershell. I am looking for a script to perform an ftp upload. I found the script below. I made changes to the variable values. The variables values below are not mine.
$Username = "FTPUSER"
$Password = "Passw0rd"
$LocalFile = "C:\Temp\file.zip"
$RemoteFile = "ftp://thomasmaurer.ch/downloads/files/file.zip
# Create a FTPWebRequest
$FTPRequest = [System.Net.FtpWebRequest]
$FTPRequest.Credentials = New-Object System.Net.NetworkCredenti
$FTPRequest.Method = [System.Net.WebRequestMeth
$FTPRequest.UseBinary = $true
$FTPRequest.KeepAlive = $false
# Send the ftp request
$FTPResponse = $FTPRequest.GetResponse()
# Get a download stream from the server response
$ResponseStream = $FTPResponse.GetResponseSt
# Create the target file on the local system and the download buffer
$LocalFileFile = New-Object IO.FileStream ($LocalFile,[IO.FileMode]:
[byte$ReadBuffer = New-Object byte 1024
# Loop through the download
$ReadLength = $ResponseStream.Read($Read
while ($ReadLength -ne 0)
When I run I get the following error shown in the attachment
which just keeps repeating. I guess due to the loop. The file does not transfer. Please let me know if any additional infomation is needed.