Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

joesyuh

Resume Support will not turn off in Powershell Script

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.

try

{
    # 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
 
    try
    {
        # Connect
        $session.Open($sessionOptions)
 
        $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()
        }

    }

    finally
    {
        # Disconnect, clean up
        $session.Dispose()
    }
 
    #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?