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

The Function

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

How to output objects from your own PowerShell functions

This example of PowerShell code shows how to output objects from your own functions. The basic tasks you do to accomplish this in your function are:

  1. Assemble the values into a hash table
  2. Create an object using that hash table
  3. Output the object

Once you do this, then you can treat your output as you would any other object in PowerShell.

  1. Assemble the values into a hash table
    • See my example below, it is the lines like $Properties =  @{…}
    • More info at about_Splatting
  2. Create an object using that hash table
    • See my example, the line starting with $Object = New-Object…
  3. Output the object
    • Simply Write-Output $Object