Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function Get-DownloadSpeed
{
[CmdletBinding()]
Param
(
# Param1 help description
[Parameter(Mandatory=$true, Position=0)]
$SpeedtestServer,
# Param2 help description
[Parameter(Mandatory=$true, Position=1)]
$DownLoad
)
Process
{
[string]$testurl = $SpeedtestServer + $DownLoad
try {
$Error = $null
$time = measure-command {$dl = Invoke-WebRequest -uri $testurl -TimeoutSec 1}
} catch {
write-host "Error downloading $testurl "
write-host $dl
break
}
$result = $($dl.RawContentLength) / $($time.totalseconds)
$resultmb = $result / 1000000
$resultmb = [math]::Round($resultmb,2) #round to 2 decimal places
$dlmb = $($dl.RawContentLength) / 1000000
$dlmb = [math]::Round($dlmb,2)
$secs = $($time.totalseconds)
$secs = [math]::Round($secs,2)
Write-host "$testurl downloaded $dlmb Mbit in $secs seconds at $resultmb Mbit/s"
}
}
$dl500 = "/speedtest/random500x500.jpg"
$dl1000 = "/speedtest/random1000x1000.jpg"
$dl2000 = "/speedtest/random2000x2000.jpg"
$testserver = "www.irongoat.net/speedtest"
#Get-DownloadSpeed $testserver $dl500
#Get-DownloadSpeed $testserver $dl1000
Get-DownloadSpeed $testserver $dl2000
@bklockwood

This comment has been minimized.

Copy link
Owner Author

commented Apr 4, 2015

A typical response:

www.irongoat.net/speedtest/speedtest/random2000x2000.jpg downloaded 7.91 Mbit in 2.51 seconds at 3.15 Mbit/s

Using the speedtest.net web interface pointed at this same server, 70Mbit/sec results are common. Never as low as 3Mbit/sec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.