Powershell SFTP script not correctly pulling file

  • I have a powershell script to download a large zip file using SFTP protocol and WinSCP that I'm having trouble with. I've got a lot of issues I'm trying to resolve with this but the main one is this... When I first started running it manually, it worked wonderfully. The past few weeks, though, it's like it can't seem to complete the download...

    The script runs successfully. I see the zip on the destination NAS. When I try to extract the file, though, I get an error and the file is only 1 KB. When I manually download the zip through the WinSCP GUI, I see what I manually downloaded it is actually slightly smaller (105k) than the version powershell downloaded (106k), and I can extract the file without error.

    This is very confusing to me. I'm not sure why powershell would increase a zip size during the download process but I'm sure it's related to the extract error I'm getting. And as I said above, the powershell script worked fine for a month before it started having this problem.

    Any thoughts on what I should be looking at?

     

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • It would help if we could see the code you are using - and any error messages.  I use WinSCP to upload files within an SSIS package - and use the .NET control to do the work.  If you are not using the .NET version - it might be a better option and you can review here: https://winscp.net/eng/docs/library_powershell

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • make sure the powershell version is setting the "Binary" mode for transfer - if not and if the default is not binary it will mess it up.

  • To be honest, it sounds to me that the file at the source is damaged.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • frederico_fonseca wrote:

    make sure the powershell version is setting the "Binary" mode for transfer - if not and if the default is not binary it will mess it up.

    Oh, good grief. I didn't even notice that the script somehow changed from Binary to Ascii. Thank you!

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply