Upload multiple files from source directory through Powershell
So the problem is that I have 40 files in a directory. Add the moment if I use my Script which I will post below it will upload all the files but it takes ages.
So what I want is that the script downloads 6 or 8 files add the same time. Is this possible and if so how can I do it.
So what I want is that the script downloads 6 or 8 files add the same time. Is this possible and if so how can I do it.
#Upload data to LivingStone SFTP try { # Load WinSCP .NET assembly Rember The folder must contain winscpnet.dl and WinSCP.exe Add-Type -Path "C:\Powershell\LivingStone_SFTP\WinSCPnet.dll" # Setup session options $sessionOptions = New-Object WinSCP.SessionOptions $sessionOptions.Protocol = [WinSCP.Protocol]::Sftp $sessionOptions.HostName = $sessionOptions.UserName = $sessionOptions.Password = $sessionOptions.SshHostKeyFingerprint = $session = New-Object WinSCP.Session try { # Connect $session.Open($sessionOptions) # Upload files $transferOptions = New-Object WinSCP.TransferOptions $transferOptions.TransferMode = [WinSCP.TransferMode]::Binary $TransferOptions.PreserveTimestamp = $false $TransferOptions.ResumeSupport.State = [WinSCP.TransferResumeSupportState]::on #here we define source and destination $transferResult = $session.PutFiles("D:\Backups\SCCM\*", "/inbox/", $False, $transferOptions) # Throw on any error $transferResult.Check() # Print results foreach ($transfer in $transferResult.Transfers) { Write-Host ("Upload of {0} succeeded" -f $transfer.FileName) } } finally { # Disconnect, clean up $session.Dispose() } exit 0 } catch [Exception] { Write-Host $_.Exception.Message exit 1 }[/quote]