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.
Have fun measuring your download speed.
Categories: PowerShell
Hello! For your Speed variable computation, how did you arrive at using 0.889 as a constant?
LikeLike
I have added a few lines to the code, so it should be more clear.
LikeLike