PowerShell function to calculate data transfer time

This PowerShell function will calculate how long it will take to transfer a given number of bytes at a given speed (in bits per second). Optionally, you can specify transfer overhead, which defaults to ten percent.

Example Usage

PS C:\> Get-TransferTime -FileSize 4.4gb -Speed 2mb

Days         : 0
Hours        : 5
Minutes      : 0
Seconds      : 22
TotalDays    : 0.208587962962963
TotalHours   : 5.00611111111111
TotalMinutes : 300.366666666667
TotalSeconds : 18022

The Function

Data transfer time calculation.
Calculate how long it would take to transfer a given number of bytes at a given speed.
File Size in bytes. Can specify with GB, MB, etc.
Transfer speed in bits. Can specify with GB, MB, etc.
.PARAMETER OverheadPercent
Transfer overhead percent. Defaults to 10.
Get-TransferTime -FileSize 4.4gb -Speed 2mb
Get-TransferTime -FileSize 50mb -Speed 10mb -OverheadPercent 6
Ken Bradley, 2015-12-10
function Get-TransferTime
        [double]$FileSize, # bytes, can specify GB, MB, etc

        #Speed help!
        [double]$Speed, # bits, can specify GB, MB, etc


    # Scale percent so 100% = 1.0
    $ScaledPercent = 1 + ($OverheadPercent / 100)
    # Calculate seconds
    $Result = ($FileSize * 8 * $ScaledPercent) / $Speed

    # Output the result nicely formated
    New-TimeSpan -Seconds $Result | Format-List -Property Days, Hours, Minutes, Seconds, TotalDays, TotalHours, TotalMinutes, TotalSeconds

[EDIT: Previously, there was an error with OverheadPercent being excluded from the calculation. It has been added back. Thanks to JG for catching this.]


  1. JG

    Where do you use the OverheadPercent param in your calculation??

  2. JG: OverheadPercent was left out. Thanks for noticing that. I’ve updated the post to include it.

Leave a Reply

Your email address will not be published. Required fields are marked *