Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move-SFTPItem missing a -force parameter #553

Closed
ChrisRe-Lal opened this issue Nov 3, 2023 · 3 comments
Closed

Move-SFTPItem missing a -force parameter #553

ChrisRe-Lal opened this issue Nov 3, 2023 · 3 comments

Comments

@ChrisRe-Lal
Copy link

ChrisRe-Lal commented Nov 3, 2023

Hello,

When moving an item between folder if the file name already exist in the destination we get an error.

[DBG]: PS C:\SCRIPT>> Move-SFTPItem -SessionId $SSHSesstion.SessionId -Path "./$($_.Name)" -Destination "./PDF/$($_.Name)"
Exception calling "MoveTo" with "1" argument(s): "Failed to rename file/home/abc@null.null_UUID_106_5/fakt_20231029_50014114.p.202954.pdf M: Error during remote request handle."
At C:\Program Files\WindowsPowerShell\Modules\Posh-SSH\3.1.1\Posh-SSH.psm1:1393 char:17
+                 $itemInfo.MoveTo($Destination)
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SftpPathNotFoundException

Having a -Force option which would allow to automatically replace the file in the destination would be a great addition.

Chris

@darkoperator
Copy link
Owner

Sadly SSH.NET method for moving a file does not have a Overload that will allowme to force a move even if a file exists

image

So made it where it checks if it exists and it it does and -Fode is used it will delete then move. This will ne in the next release

image

darkoperator added a commit that referenced this issue Aug 31, 2024
Adds support of deleteing then moving a file with the use of the -force parameter in move-sftpItem to address feature request #553
@darkoperator
Copy link
Owner

Updated in release 3.2.2

@ChrisRe-Lal
Copy link
Author

Thanks a lot.
Will test it and let you know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants