darkoperator / darkoperator/Posh-SSH
Download a folder with Get-SFTPItem
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 1.1k
- Forks
- 222
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I have an issue with the cmlet "Get-SFTPItem". I want to download one or more folder(s) with this command
Get-SFTPChildItem $sftpsession -Path $source | Where-Object {$_.Name -notlike "*.*"} | ForEach-Object {
Get-SFTPItem $sftpsession -Path $_.FullName -Destination E:\Test\ -NoProgress
}
With a normal behivor, the command will download all folder to the $path in the local server. But have this error :
Get-SFTPItem : Could not find a part of the path 'E:\Test\XXXX_20190502\XXXX_20190502.zip'.
At line:1 char:104
+ ... ach-Object {Get-SFTPItem $sftpsession -Path $_.FullName -Destination ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-SFTPItem], DirectoryNotFoundException
+ FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,SSH.GetSftpItem
So the command download every file in the folder but not the folder itself... If I add a command to create the folder in local server I have this error
Get-SFTPItem : Item /tmp/backups/XXXX_20190502 already present on local host.
At C:\Users\Administrator\Desktop\script automatisation.ps1:24 char:9
+ Get-SFTPItem $sftpsession -Path $_.FullName -Destination $pat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (SSH.SftpSession:SftpSession) [Get-SFTPItem], SftpPermissionDeniedException
+ FullyQualifiedErrorId : Item /tmp/backups/futurcgi_20190502 already present on local host.,SSH.GetSftpItem
In this case, the cmlet crash because the folder already exist...
Do you have a solution for that ?
Thanks,
Regards,
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Get-SFTPItem entry point and reproduce the two command examples: downloading a remote folder with and without creating its local destination first. Done means folder downloads work without a missing-path error and an existing local folder does not cause the cmdlet to fail.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100