Doing a speedtest with PowerShell

This topic contains 6 replies, has 2 voices, and was last updated by Profile photo of Jean-Paul Jean-Paul 3 years, 4 months ago.

  • Author
    Posts
  • #13031
    Profile photo of Jean-Paul
    Jean-Paul
    Participant

    Hi guys!

    I searched a lot on Google, but most scripts are not working or only showing the link speed from the network card (100/1000). I would like to do a speedtest with PowerShell so I can include the internet speed in my report. Is that possible?
    I'm still a newbie on PowerShell (19 years old), so I'm sorry if this is easy to make. 🙂

    Thanks.

    Best regards,

    Jean-Paul

  • #13041
    Profile photo of Robert Westerlund
    Robert Westerlund
    Participant

    Before considering implementation for a speedtest, you need to define what you mean when you say network speed. How do you define network speed (is it pure upload/download speed for TCP communication between computer A and B or is it something else you're looking for) and between which endpoints (exactly which computers are you going to use and are they two computers on same local network, other country, other side of the globe)?

  • #13043
    Profile photo of Jean-Paul
    Jean-Paul
    Participant

    Hi Robert. Thanks for your answer. It must be something like speedtest.net. So it's pure upload and download speed between a (public, maybe speedtest.net if possible) server.

  • #13044
    Profile photo of Robert Westerlund
    Robert Westerlund
    Participant

    To calculate pure upload and download speed is pretty easy, especially if you have control over both the server and the client. Just make UploadFile and DownloadFile requests (which you can do using the Invoke-WebRequest cmdlet or the HttpClient or WebClient .NET classes), measure the time it takes and divide the file size with the time measured. Do be sure to upload both small and slightly larger files, to account for connection opening and similar.

    However, if the server is not yours and you keep downloading and uploading a lot of large dummy files (especially if you run it from several different machines at the same time) it could be considered less nice (bordering on DOS-attack, possibly?), in which case I suggest contacting the server owner before doing any such thing.

  • #13045
    Profile photo of Jean-Paul
    Jean-Paul
    Participant

    OK, that's also possible indeed. I'd hoped for something like Speedtest.net in PowerShell, but that's not possible so I have to make my own speedtest. 🙂 Thanks for the commands and help!

  • #13046
    Profile photo of Robert Westerlund
    Robert Westerlund
    Participant

    Speedtest.net is a flash application, so it's not really a great fit for controlling via PowerShell. In theory you could automate the webbrowser to start the speedtest.net test and once it's done somehow get the data out of the flash application (either if it's available through some javascript calls to the flash API, peeking into the flash gui objects or by doing OCR on the flash GUI displaying the numbers). I do, however, believe that this would be a lot more difficult (have never tried controlling flash applications from PowerShell so I can't make any educated comments on the difficulty level) than just making the calculations yourself (which should be pretty easy, once you know which server you want to communicate with).

  • #13048
    Profile photo of Jean-Paul
    Jean-Paul
    Participant

    No indeed. Thanks for the help Robert!

You must be logged in to reply to this topic.