tomohulk / WinSCP

WinSCP PowerShell Wrapper Module
GNU General Public License v3.0
153 stars 30 forks source link

error occurred while setting the permissions and/or timestamp.** #127

Closed Gaz2600 closed 4 years ago

Gaz2600 commented 4 years ago

Please fill in the following fields, replacing the values inside the brackets {{ }}.

Issue Description

We have a new service whos sftp server is giving me an error when uploading "error occurred while setting the permissions and/or timestamp.**" from what I've found you need to use new-winscptransferoption and new-winscpitempermission however I've not been able to get them to work

Example

$transOptions = New-WinSCPTransferOption -PreserveTimestamp:$false -FilePermissions (New-WinSCPItemPermission -UserRead -UserWrite -GroupRead -OtherRead)

Send-WinSCPItem -WinSCPSession $session -Path $srcStuHmLang -Destination $filename -TransferOptions $transOptions 

Send-WinSCPItem : WinSCP.SessionRemoteException: **Upload of file 'ParentSquare_Student-HmLang-Cell.csv' was successful, but error occurred while setting the permissions and/or timestamp.**
If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option.
The server does not support the operation.
Error code: 8
Error message from server (US-ASCII): SETSTAT unsupported
At line:1 char:9
+         Send-WinSCPItem -WinSCPSession $session -Path $srcStuHmLang - ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Send-WinSCPItem

Expected Output

{{ Please provide what expect to happen. }}

Actual Output

{{ Please provide what actually happened. }}

WinSCP-PowerShell Version

Version 5.13.9.1

Environment

Windows 2019 Datacenter 64 bit

Name : Windows PowerShell ISE Host Version : 5.1.17763.1007 InstanceId : 4f74bab2-88e8-451b-ac18-0396ca43d083 UI : System.Management.Automation.Internal.Host.InternalHostUserInterface CurrentCulture : en-US CurrentUICulture : en-US PrivateData : Microsoft.PowerShell.Host.ISE.ISEOptions DebuggerEnabled : True IsRunspacePushed : False Runspace : System.Management.Automation.Runspaces.LocalRunspace

The FTP server is managed AWS SFTP server

tomohulk commented 4 years ago

Lets see if we can figure this out, I haven't seen this exact issue, I also don't have an AWS sub, so its going to be hard for me to test.

first, can you update to the latest WinSCP PowerShell Module Version, 5.17.2.0, you are quite a few versions behind.
if you downloaded it from the powershell gallery, just do Update-Module WinSCP else you can grab it from the releases section here on the project page.

next, try just using the transfer options, I don't think you need to change the permissions at all

$transOptions = New-WinSCPTransferOption -PreserveTimestamp:$false

lte me know how it goes. thanks.

Gaz2600 commented 4 years ago

That appears to have allowed the transfer when I ran a small portion of the script but running the entire script I now get a new error:

`New-WinSCPSession: Exception calling "Open" with "1" argument(s): "The version of C:\Program Files\WindowsPowerShell\Modules\WinSCP\5.17.2.0\Public..\bin\winscp.exe (5.17.2.0) does not match version of this assembly C:\Program Files\WindowsPowerShell\Modules\WinSCP\5.13.9.1\lib\WinSCPNet.dll (5.13.9.0)." At E:\ParentSquare\PS\ParentSquare.ps1:51 char:16

tomohulk commented 4 years ago

you need to close and reopen your console, the old dll is still loaded. you can also just go delete C:\Program Files\WindowsPowerShell\Modules\WinSCP\5.13.9.1 if you want to be sure

Gaz2600 commented 4 years ago

ah excellent, easy fix. everything appears to be working now, thank you!

tomohulk commented 4 years ago

hey no problem, glad its working for you!