Topic "Resume Support will not turn off in Powershell Script"

Author Message
[View user's profile]

Joined: 2015-01-09
Posts: 4
I am currently trying to upload to a location where it appears I do not have the rights to rename files. I am attempting to turn off resumesupport but I am having now luck. I have written my script in powershell.

    # Load WinSCP .NET assembly
    Add-Type -Path "C:\WinSCP\WinSCPnet.dll"
    # Setup session options
    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::Sftp
        HostName = "XXXXX"
        UserName = "XXXXX"
        Password = "XXXXX"
        SshHostKeyFingerprint = "XXXXX"
    #setup transfer options
    $transferOptions = New-Object WinSCP.TransferOptions
    $transferOptions.ResumeSupport.State = [WinSCP.TransferResumeSupportState]::off
    $session = New-Object WinSCP.Session
        # Connect
        $remotePath = "/XXXXX/XXXXX/"       
        foreach ($MCRline in $MCRFileList)
            $MCRline = $MCRFilePath + $MCRline
            Write-Host ("Uploading {0} ..." -f $MCRline)
            $session.PutFiles($MCRline, $remotePath, $transferOptions).Check()

        foreach ($MCDline in $MCDFileList)
            $MCDline = $MCDFilePath + $MCDline
            Write-Host ("Uploading {0} ..." -f $MCDline)
            $session.PutFiles($MCDline, $remotePath, $transferOptions).Check()

        foreach ($HAPline in $HAPFileList)
            $HAPline = $HAPPrimaryFilePath + $HAPline
            Write-Host ("Uploading {0} ..." -f $HAPline)
            $session.PutFiles($HAPline, $remotePath, $transferOptions).Check()

        foreach ($BCBSMline in $BCBSMFileList)
            $BCBSMline = $BCBSMFilePath + $BCBSMline
            Write-Host ("Uploading {0} ..." -f $BCBSMline)
            $session.PutFiles($BCBSMline, $remotePath, $transferOptions).Check()


        # Disconnect, clean up
    #exit 0
catch [Exception]
    Write-Host ("Error: {0}" -f $_.Exception.Message)
    exit 1

Even with this line:
$transferOptions.ResumeSupport.State = [WinSCP.TransferResumeSupportState]::off

I am still receiving this error:
Error: Transfer was successfully finished, but temporary transfer file '06172016_082224.835.filepart' could not be renamed t
o target file name '06172016_082224.835'. If the problem persists, you may try to turn off transfer resume support.

Any advice on what I am doing wrong?
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24757
Location: Prague, Czechia
The TransferOptions options is the 4th, not the 3rd argument of Session.PutFiles:

$session.PutFiles($MCRline, $remotePath, $False, $transferOptions).Check()

You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License