Note that there are some explanatory texts on larger screens.

plurals
  1. POFTP Upload from .csv input with Powershell
    primarykey
    data
    text
    <p>So....I have piced together a script from some of the other posts here, but I have 2 remaining issues I cannot seem to figure out. The first issue is the upload fails when the file is over 2MB. It appears to time out, and I'm not sure why. Is there a better way to upload files that are around 8-12 MB? The second issue (not a really a huge issue), is how to change the directory to upload the file to. I have a scenario wher the default FTP ROOT directory is /ann and I need to FTP to just /. Is that possible to log in and then CD /?</p> <pre><code>en# This script is to upload firmware to various IP Addresses in the Avaya sytem(s) #Prompt the user for the ftp username and password $ftp_username = Read-Host "What is the ftp username" $ftp_password = Read-Host "What is the ftp password" #Define and read in the .csv file $importlist = import-csv c:\firmware-updates.csv # This is where we start the loop foreach($upload in $importlist) { # Define varaibles from the import file. $board = $upload.Board $firmware = $upload.Firmware $IPaddress = $upload.IP # create the FtpWebRequest and configure it $ftp = [System.Net.FtpWebRequest]::Create("ftp://$IPaddress/$firmware") $ftp = [System.Net.FtpWebRequest]$ftp # Set the FTP method (upload/download) $ftp.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile # Pass the username and password to the server $ftp.Credentials = new-object System.Net.NetworkCredential("$ftp_username","$ftp_password") # Set the modes $ftp.UseBinary = $true $ftp.UsePassive = $true # read in the file to upload as a byte array # Original Byte Array caused memorey error #$content = [System.IO.File]::ReadAllBytes("C:\$firmware") $content = gc -en Byte ("C:\$firmware") $ftp.ContentLength = $content.Length # get the stream request $rs = $ftp.GetRequestStream() $rs.Write($content, 0, $content.Length) echo "File $firmware is being upoaded to $IPaddress for board $board" # clean up after ourselves $rs.Close() $rs.Dispose() $firmware.Close() } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload