Advertisement
hl2guide

Internet Speed Test 1.0A - PowerShell

Jul 30th, 2017
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Runs a speed test by downloading a 10MB file temporarily
  2. # Version: 1.0A
  3. # Author: hl2guide
  4.  
  5. # Only run this script after stopping all other traffic/downloads (isolated test).
  6.  
  7. # Expected Internet Speed (in Mbps)
  8. $expectedLineSpeed = 11
  9. # Download File Size (10 or 100)
  10. $testFileSize = 10
  11.  
  12. $fileToDownload = 'http://client.akamai.com/install/test-objects/'+ $testFileSize +'MB.bin'
  13. # $fileToDownload = 'http://mirror.nforce.com/pub/speedtests/'+ $testFileSize +'MB.bin'
  14. # $fileToDownload = 'http://speedtest.serverius.net/files/'+ $testFileSize +'MB.bin'
  15.  
  16. $message = 'Testing Internet Speed (' + $testFileSize + 'MB file), please wait...'
  17. Write-Host
  18. Write-Host
  19. Write-Host
  20. Write-Host
  21. Write-Host $message -ForegroundColor Cyan
  22.  
  23. # Start Internet Speed Test
  24. $a=Get-Date
  25. Invoke-WebRequest $fileToDownload|Out-Null
  26. $result = "$((10/((Get-Date)-$a).TotalSeconds)*8)"
  27. $result = [math]::Round($result, 3)
  28.  
  29. # Outcomes
  30. if($result -gt $expectedLineSpeed - 1)
  31. {
  32.     $outTextColor = 'Green'
  33.     $speed = 'great'
  34. }
  35. elseif($result -gt $expectedLineSpeed - 2)
  36. {
  37.     $outTextColor = 'Magenta'
  38.     $speed = 'fine'
  39. }
  40. elseif($result -gt $expectedLineSpeed / 2)
  41. {
  42.     $outTextColor = 'Yellow'
  43.     $speed = 'passable'
  44. }
  45. else
  46. {
  47.     $outTextColor = 'Red'
  48.     $speed = 'slow'
  49. }
  50.  
  51. # Output Result
  52. $message = 'Download Speed Result: ' + $result + ' Mbps' + ' ('+ $speed + ')'
  53. Write-Host
  54. Write-Host $message -ForegroundColor $outTextColor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement