Download a folder with Get-SFTPItem
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,
Looking in to it
Sent from my iPhone
On May 4, 2019, at 4:37 PM, rvftskill [email protected] wrote:
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 :
'''powershell 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 : '''powershell
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,
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
found the issue, fixing it and doing tests, will do a release Monday with the fix.
Awesome ! Thank you !
Hello ! I see you have commited the fixe for this issue. Do you know when the 2.2 will be release ? Or can I install the fix ?
Thanks, Regards,
Tonight
Sent from my iPhone
On May 11, 2019, at 9:54 AM, rvftskill [email protected] wrote:
Hello ! I see you have commited the fixe for this issue. Do you know when the 2.2 will be release ? Or can I install the fix ?
Thanks, Regards,
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
Hello, im trying to use get-sftpitem from a linux based ftp server to windows based destination.
I used:
Get-SFTPItem -SessionId ($SFTPSession).SessionId -Path /LinuxFolder -Destination d:\WindowsFolder
Error that I got:
Get-SFTPItem : The given path's format is not supported. At line:10 char:2 Get-SFTPItem -SessionId ($SFTPSession).SessionId -Path /LinuxFolder -De ... CategoryInfo : NotSpecified: (:) [Get-SFTPItem], NotSupportedException FullyQualifiedErrorId : System.NotSupportedException,SSH.GetSftpItem
Appreciate if you can help on this, thanks!