Exception calling "Check" with "0" argument(s): "Upload of file '2019-06-11.zip' 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. Permission denied. Error code: 3 Error message from server: This server does not support operations to modify file attributes." At line:12 char:84 + $session.PutFiles("D:\Users\bin\*.zip", "/Outbox/").Check <<<< () + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
I keep on getting above error file transferring file from Window Server to Linux. I got the same error when using the WinSCP GUI as well. I asked MFT team and they didn't any set permission. Below are my script for file transferring and some of intro version of software I'm using. Anything I missed out for my script or version of software is too old? I will have an update of server soon but have to wait another 2 yrs. This task will be set as scheduler to transfer file daily to MFT server.
Version of software:
- Use .NET 4.0
- Use PowerShell v2.0
- Window Server 2008
- Placed
private.ppk
,WinSCPNet.dll
andWinSCP.exe
at same folder
#Load WinSCP .NET assembly
Add-Type -Path "D:\Users\WinSCPnet.dll" -Verbose
$session = New-Object WinSCP.Session
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = "[Linux server IP]"
$sessionOptions.UserName = "[username]"
$sessionOptions.PortNumber = "[linux port number]"
$sessionOptions.Password = ""
$sessionOptions.SshPrivateKeyPath = "D:\Users\bin.ppk"
$sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 ....="
try {
# Open the WinSCP.Session object using the WinSCP.SessionOptions object.
$session.Open($sessionOptions)
# Upload
$session.PutFiles("D:\Users\bin\*.zip", "/Outbox/").Check()
} finally {
# Disconnect, clean up
$session.Dispose()
}