PowerShell

Measure Link Speed (Bandwith) with PowerShell

Recently I have been working on a script which should check the download speed. With PowerShell of course. I would like to share it here.

The Code

Here is my code for colleting information about my download speed and my link speed.

Enter the URL of the file to download and provide the location of the downloaded file.

$File  = 'https://patrick6649.files.wordpress.com/2022/08/lektion18.mp4'
$Location = Join-Path -Path $Home -ChildPath "Downloads\lektion18.mp4"

$time = Measure-Command {
    Start-BitsTransfer -Source $File -Destination $Location 
    
} | Select-Object -ExpandProperty TotalSeconds

$filesize = (Get-ChildItem -Path $Home\Downloads\lektion18.mp4).Length/1MB

$Speed = ($filesize / $time) * 8

Write-Output "Network Speed: $([math]::Round($Speed,2)) Mbit/sec"

Short explanation: A file will be downloaded from my homepage. It’s a video about Powershell Profiles in German language. During the download of the file the process is measured with the Measure-Command cmdlet. At the end we get the final result and the time it took to download the file.

Credits

Credits goes to the author of this blog posts who sparks the idea in to write this script.

https://www.joakimnordin.com/is-it-possible-to-check-the-internet-performance-at-a-clients-network-using-powershell/

Have fun measuring your download speed.

Categories: PowerShell

Tagged as: ,

3 replies »

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.