Skip to content

Move-SFTPItem missing a -force parameter #553

@ChrisRe-Lal

Description

@ChrisRe-Lal

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions