PowerShell – Automation – FileTransferProgress – Volume transferred

Advertisement

Claudio1983
Guest

PowerShell – Automation – FileTransferProgress – Volume transferred

Hi to all!
I need to expose the progress of file being transferred.
At the moment the script look like this:
function FileTransferProgress
{
    param($e)
    # New line for every new file
    if (($script:lastFileName -ne $Null) -and
        ($script:lastFileName -ne $e.FileName))
    { Write-Host }
    # Print transfer progress
    Write-Host ("`r{0} ({1:P0})" -f $e.FileName, $e.FileProgress)
    # Remember a name of the last file reported
    $script:lastFileName = $e.FileName
}
 
[...] #some stuff
$session.add_FileTransferProgress( { FileTransferProgress($_) } )
[...] #some stuff
This way, I get the percentage. What I need is the volume (if possible).
Thanks in advance for any help.
Full script attached if useful.
Have a nice day!

Claudio
Description: Full script

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: PowerShell – Automation – FileTransferProgress – Volume transferred

WinSCP .NET assembly currently does not expose number of bytes transferred. But as you are uploading, you can query the size of the source file and estimate the bytes uploaded based on the FileProgress:
(Get-Item $e.FileName).Length * $e.FileProgress

Reply with quote

Advertisement

You can post new topics in this forum