ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    [Solved] Bat File Uploading CSV via FTP - Works from Server 2008 R2, 0KB File on FTP from 2012 R2

    IT Discussion
    ftp powershell windows server 2012 r2 windows server 2008 r2
    1
    2
    977
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • wrx7mW
      wrx7m
      last edited by wrx7m

      I have a strange issue. We recently migrated our ERP from a Windows Server 2008 R2 VM to a 2012 R2 VM. We have a scheduled task that runs a bat file using powershell (calling old school built-in Windows FTP client) to upload a CSV file (that the ERP software generates) to our website server via FTP.

      Ever since we migrated, it hasn't properly updated the site. Upon further inspection, I can see that the file is only created/named on the FTP side and is 0KB. I have tested the bat file manually, by doing a run as administrator and it does the same thing.

      I went back and verified the old server is still working fine. I am wondering if there has been a change in the way that powershell handles it. I didn't create the bat file, the VAR for our ERP solution did it a couple of years ago.

      Here is the breakdown. Does anyone know why this doesn't work on 2012 R2?

      Bat file contents-

      powershell ftp -s:C:\ps\FTP\NightlyFTP.txt

      NightlyFTP.txt contents-

      open 10.20.30.40
      ftpUsername
      ftpPassword
      put D:\Data\FTP.CSV
      quit
      pause

      1 Reply Last reply Reply Quote 2
      • wrx7mW
        wrx7m
        last edited by

        I ended up going with an upgraded script by truly using powershell.

        I found the answer here -
        https://stackoverflow.com/questions/936108/how-to-script-ftp-upload-and-download

        Essentially this is the script:

        $File = "D:\Dev\somefilename.zip"
        $ftp = "ftp://username:[email protected]/pub/incoming/somefilename.zip"

        "ftp url: $ftp"

        $webclient = New-Object System.Net.WebClient
        $uri = New-Object System.Uri($ftp)

        "Uploading $File..."

        $webclient.UploadFile($uri, $File)

        1 Reply Last reply Reply Quote 1
        • 1 / 1
        • First post
          Last post