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

IJH

Re: transfer.Options File Permissions

Thanks Martin - worked a treat.


So the code should be:

$session.PutFiles($localPath, $remotePath, $False, $transferOptions)
IJH

transfer.Options File Permissions

Hi,

I'm trying to set the transfer options to ignore file permissions and timestamps but i'm still receiving the error back from the server:


< 2019-02-28 10:23:16.188 Error message from server: This server does not support operations to modify file attributes. File attributes for [/Inbox/move_me.xml] were not modified.
* 2019-02-28 10:23:16.189 (ESkipFile) **Upload of file 'move_me.xml' was successful, but error occurred while setting the permissions and/or timestamp.**
* 2019-02-28 10:23:16.189
* 2019-02-28 10:23:16.189 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option.
* 2019-02-28 10:23:16.189 Permission denied.


code is here:
try

    {

        # Connect
        $session.Open($sessionOptions)
       
 
        # Set options, upload files, collect results
        $transferOptions = New-Object WinSCP.TransferOptions
        $transferOptions.FilePermissions = $Null
        $transferOptions.PreserveTimestamp = $False
        $transferResult = $session.PutFiles($localPath, $remotePath, $transferOptions)


        # Iterate over every transfer
        foreach ($transfer in $transferResult.Transfers)
        {
            # Success or error?
            if ($transfer.Error -eq $Null)
            {
                Write-Host "Upload of $($transfer.FileName) succeeded, moving to backup"
                # Upload succeeded, move source file to backup
                Move-Item $transfer.FileName $successPath
            }
            else
            {
                Write-Host "Upload of $($transfer.FileName) failed: $($transfer.Error.Message)"
            }
        }

    }
    finally
    {
        # Disconnect, clean up
        $session.Dispose()
    }


Any ideas why its not passing or being ignored by the server perhaps?

PS C:\Users\xxxxxx> $transferOptions



PreserveTimestamp : False
FilePermissions   :
TransferMode      : Binary
FileMask          :
ResumeSupport     : default
SpeedLimit        : 0
OverwriteMode     : Overwrite