EvotecIT / Transferetto

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

Example06-UploadFTPS.ps1 #1

Closed Mahmoud87 closed 3 years ago

Mahmoud87 commented 3 years ago

This is not an issue, thanks for the awesome script, is there a way to copy child items within a directory with having the same sort of validation to update or skip. Thank you so much

PrzemyslawKlys commented 3 years ago

Sorry for the late response. I haven't had a chance to test it. But doing it manually file by file (with Recursive switch on Get-ChildItem) with CreateRemoteDirectory should work properly.

Mahmoud87 commented 3 years ago

Thanks for your reply, it will be so tough copying thousands of files. Appreciate your response though.

On Thu, 26 Aug 2021, 3:05 am Przemysław Kłys, @.***> wrote:

Sorry for the late response. I haven't had a chance to test it. But doing it manually file by file with CreateRemoteDirectory should work properly.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/EvotecIT/Transferetto/issues/1#issuecomment-905735806, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE6BXF4JCJXRYZUZJIL32WDT6USV5ANCNFSM5CJRQGXQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

PrzemyslawKlys commented 3 years ago

by manually I mean you can write some additional code that should help you. It shouldn't be more than 20 lines of code to do it.

Mahmoud87 commented 3 years ago

by manually I mean you can write some additional code that should help you. It shouldn't be more than 20 lines of code to do it.

Hi mate, I am trying but I am seeing different results, so I have started with few lines and uploading directories. Here is the script.

` $Client = Connect-FTP -Server 'ftp://caqq.com' -Verbose -Username '67p' -Password 'avv33'

$sourceFolder = 'F:\New folder\2695 NSW' $ListFiles = Get-ChildItem $sourceFolder -recurse -File -ErrorAction SilentlyContinue $LocalDir = Get-ChildItem $sourceFolder -Directory

Foreach ($Dir in $LocalDir){ Send-FTPDirectory -LocalPath $Dir.fullname -Client $Client -RemotePath "/x11/xx/Test/Test" -Verbose

Write-Host "Uploading" $Dir

Start-Sleep -Seconds 2 } Disconnect-FTP -Client $Client `

When I list my $localdir this is what I get; Directory: F:\New folder\2695 NSW

Mode LastWriteTime Length Name


d----- 24/08/2021 5:00 AM 13 Trelawney ADD
d----- 23/08/2021 8:29 PM Acoustic Report
d----- 23/08/2021 8:29 PM Architectural Drawings
d----- 24/08/2021 5:23 AM Architectural Schedules
d----- 23/08/2021 8:29 PM COSTING TOOL
d----- 23/08/2021 8:29 PM Electrical Services
d----- 23/08/2021 8:29 PM Hydraulic Services
d----- 23/08/2021 8:29 PM Lift Services
d----- 23/08/2021 8:29 PM Mechanical Services
d----- 23/08/2021 8:29 PM PPR
d----- 23/08/2021 8:29 PM Woollarah Embassy

When I check the FTP server This is what gets uploaded from the $localdir Addendum 01 Addendum 02 Documents OLD TOOL 2uasdjjklaf.pdf Directorytest.txt WINPE10.0-DRIVERS-A23-PR4K0.CAB

The first 4 folders are actually subfolders, and the files on the root of $localdir, which I have no idea why they have got uploaded, since I haven't started to upload any files yet!!?

I will be very grateful if you could help me out.

Mahmoud87 commented 3 years ago

by manually I mean you can write some additional code that should help you. It shouldn't be more than 20 lines of code to do it.

Hi mate, I am trying but I am seeing different results, so I have started with few lines and uploading directories. Here is the script.

` $Client = Connect-FTP -Server 'ftp://caqq.com' -Verbose -Username '67p' -Password 'avv33'

$sourceFolder = 'F:\New folder\2695 NSW' $ListFiles = Get-ChildItem $sourceFolder -recurse -File -ErrorAction SilentlyContinue $LocalDir = Get-ChildItem $sourceFolder -Directory

Foreach ($Dir in $LocalDir){ Send-FTPDirectory -LocalPath $Dir.fullname -Client $Client -RemotePath "/x11/xx/Test/Test" -Verbose

Write-Host "Uploading" $Dir

Start-Sleep -Seconds 2 } Disconnect-FTP -Client $Client `

When I list my $localdir this is what I get; Directory: F:\New folder\2695 NSW

Mode LastWriteTime Length Name

d----- 24/08/2021 5:00 AM 13 Trelawney ADD d----- 23/08/2021 8:29 PM Acoustic Report d----- 23/08/2021 8:29 PM Architectural Drawings d----- 24/08/2021 5:23 AM Architectural Schedules d----- 23/08/2021 8:29 PM COSTING TOOL d----- 23/08/2021 8:29 PM Electrical Services d----- 23/08/2021 8:29 PM Hydraulic Services d----- 23/08/2021 8:29 PM Lift Services d----- 23/08/2021 8:29 PM Mechanical Services d----- 23/08/2021 8:29 PM PPR d----- 23/08/2021 8:29 PM Woollarah Embassy

When I check the FTP server This is what gets uploaded from the $localdir Addendum 01 Addendum 02 Documents OLD TOOL 2uasdjjklaf.pdf Directorytest.txt WINPE10.0-DRIVERS-A23-PR4K0.CAB

The first 4 folders are actually subfolders, and the files on the root of $localdir, which I have no idea why they have got uploaded, since I haven't started to upload any files yet!!?

I will be very grateful if you could help me out.

Please ignore this one, I got it fixed by adding "$($Dir.Name)" at the end of -RemotePath "/x11/xx/Test/Test" and it's working so far doing some testing for the files :)