I have this Code:
# Load WinSCP .NET assembly
Add-Type -Path "WinSCPnet.dll"
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = "[Windows Server host]"
UserName = "[username]"
Password = "[password]"
SshHostKeyFingerprint = "ssh-rsa 1024..."
}
# Optionally, set the "Ignore permission errors" option
$sessionOptions.AddRawSettings("SftpIgnorePermErrors", "1")
$session = New-Object WinSCP.Session
try
{
# Connect
$session.Open($sessionOptions)
# Upload
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.PreserveTimestamp = $False # Disable preserving timestamps
$transferOptions.FilePermissions = $Null # Disable setting permissions
$session.PutFiles("path\*.xlsx", "/destination/").Check()
}
finally
{
# Disconnect, clean up
$session.Dispose()
}
But I'm getting this error:
Exception calling "Check" with "0" argument(s): "**Upload of file 'filename.xlsx' 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: SSHServerAPI.SFTP.fxp_attrs"
At path\report.ps1:28 char:7
+ $session.PutFiles("path ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SessionRemoteException
Please help. I have set ReserveTimestamp to $False and FilePermissions to Null, but I'm still getting this error. I don't know if I set correctly or maybe is something else.