Session.GetFiles not able to delete remote files
I am using the following script to push and pull files from several sites without any issues. As part of the script it is set to remove the files once they have been pushed or pulled successfully. I have one site that is not allowing the script to remove the remote files after a successful
The only error message I see is the following:
Script:
GetFiles
. It appears to be something on the providers side, but I am not sure what to tell them or to get a workaround on my side. Any clues as to what's going on?
The only error message I see is the following:
Transfers Failures --------- -------- {} {WinSCP.SessionRemoteException: Error deleting file '/out/.working'....
try { $session = New-Object WinSCP.Session $OUTLocalPath = "\\SERVERNAME\OUTBOUND\*" $OUTRemotePath = "/in/" $INLocalPath = "\\SERVERNAME\INBOUND\" $INRemotePath = "./out/*" $ArhivePath = "\\\SERVERNAME\Archive\" # Make an Arvhive copy Copy-Item -Path $OUTLocalPath -Destination $ArhivePath -Recurse try { # Connect $session.Open($sessionOptions) # Upload files $transferOptions = New-Object WinSCP.TransferOptions $transferOptions.TransferMode = [WinSCP.TransferMode]::Binary $transferResult = $session.PutFiles($OUTLocalPath,$OUTRemotePath , $True, $transferOptions) $session.GetFiles($INRemotePath,$INLocalPath,$True, $transferOptions) # Throw on any error $transferResult.Check() # Print results foreach ($transfer in $transferResult.Transfers) { Write-Host "Upload of $($transfer.FileName) succeeded" } } finally { # Disconnect, clean up $session.Dispose() } #exit 0 } catch { Write-Host "Error: $($_.Exception.Message)" #exit 1 }