Topic "Show ProgressBar in PowerShell for SynchronizeDirectories download"

Author Message
[View user's profile]

Joined: 2017-09-06
Posts: 2
Location: Somewhere
Hello every1,

I'm trying to create a small powershell script to make my life a bit easier. I'm currently using the following script to sync a local directory with my remote folder and delete the remote files after the DL which works great:

But now I'd like to implement an extra progress bar for the download, just to have a visual confirmation that the script is still running if there are a LOT files to DL.

All the examples I could find (involving FileTransferProgress) only produce text output which I'd like to avoid.

Is there any way to utilize Write-Progress for a nicer output of the download? The progress bar should advance for every file that's been downloaded successfully.
PS: It doesn't have to work with the Synchronize option. GetFiles would also work for me.

[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27058
Location: Prague, Czechia
The Session.SynchronizeDirectories does not report overall progress.

But Session.GetFiles does.

I've added an example how to use Write-Progress with Session.GetFiles at the end of:
[View user's profile]

Joined: 2017-09-06
Posts: 2
Location: Somewhere
yeah. thanks.
works like a charm Smile

I just modified the funtion a little so that I have everything in just one progressbar.

function FileTransferProgress
   param ($e)
   Write-Progress `
               -Id 0 -Activity "Downloading" -CurrentOperation ("$($e.FileName) - {0:P0}" -f $e.FileProgress) -Status ("{0:P0} complete at $($e.CPS) bps" -f $e.OverallProgress) `
               -PercentComplete ($e.OverallProgress * 100)

You can post new topics in this forum


What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License