EvotecIT / Transferetto

Small PowerShell module with FTPS/SFTP functionality
MIT License
55 stars 14 forks source link

Send-FTPFile error #16

Closed FeroKli closed 2 years ago

FeroKli commented 2 years ago

Dear Przemyslaw, thank you for publishing version 0.0.14. Error with not existing function Remove-EmptyValue disappeard, but after trying to send four files using function Send-FTPFile, result of the transfer is FALSE. But there is no other error message, just FALSE after sending each file. I tried to use cmdlet Test-FTPFile, the result for 4 files is False,True,True,False,False (little bit strange five answers for 4 files). Please, have you any Idea, why transfer fail and how to solve it? Thank you. Fero

PrzemyslawKlys commented 2 years ago

Enable Set-FTPTracing -Enable and run it again, and let me know what it says.

FeroKli commented 2 years ago

Sorry, I had an error in -RemotePath switch. NOw it is working perfectly. Thank you very much :-) Fero

FeroKli commented 2 years ago

Once again... If I use switch -RemotePath "/Temporary/$($File.Name)" in cycle, status is FALSE, but when I use Sent-FTPFile at once, with -RemotePath "/Temporary" switch, it is working fine. I tried cmdlet Set-FTPTracing -Enable as you wrote, but result is always false.

Is there please any reason , why to send files in cycle, not sent them at once? Thank you Fero

PrzemyslawKlys commented 2 years ago

This is to have more control over the errors per file. I tried sending them at once and the output was only true/false from the method so I decided to loop it myself. Probably could add another option to force at once - but then you miss the output if errors occur

FeroKli commented 2 years ago

Thank you, I do understand. But in loop with -RemotePath "/Temporary/$($File.Name)" it will not send any file, all results are FALSE. (see in attachement) Have you tried it in version 0.0.14? It is working for you? image Thanks Fero

PrzemyslawKlys commented 2 years ago

Yes, if you have multiple files, you are not supposed to push a path with the file name. How do you expect the command to know which name to use? If you push just a folder name where to put file it will use that instead.

If you want to control the file name for each and every file yourself - you need to loop it yourself.

FeroKli commented 2 years ago

OK, I think, I do understand. Sorry I am not that good at programming. I just used code from your examples: https://github.com/EvotecIT/Transferetto/blob/master/Examples/Example06-UploadFTPS.ps1 image

Yes, if I use just "/TEMP" in -RemotePath switch, it is working well. Thank you wery much. Fero

PrzemyslawKlys commented 2 years ago

That seems weird that you get a message 0. The commands in a loop give Message differently

image

THe command Send-FTPFile outside of the loop gives message 0,1,2,3 depending on how many files it was able to copy.

Looking at your output image

This looks like it's trying to send 4 files to a single file and hence it's not working. If it's indeed that command giving you a problem I would check what does File.Name contains because it could be that ListFiles is not working properly.

FeroKli commented 2 years ago

Yes, it is weird. I used $File.Name in loop and it contain name of the file by file (fero.txt, fero2.txt...) image I checked version of powershel, It is 5.1. - integrated in windows. And $ListFiles image -> image

FeroKli commented 2 years ago

Dear Przemyslaw, I am really sorry, but I had a mistake in my code. I used $ListFiles.FullName instead of $File.FullName in -LocalPath switch... image I do apologize. Tank you very much. Fero