Automating Internet Speed Tests with PowerShell#
Experiencing slow internet speeds can be frustrating. With PowerShell and the Ookla Speedtest CLI, you can automate the process of testing your internet speed. This guide will walk you through setting up a script to run speed tests and save the results, which can be useful for monitoring your network’s performance or discussing issues with your ISP.
Prerequisites#
- Download and install the Ookla Speedtest CLI on your system.
- Basic understanding of PowerShell scripting.
Installing Speedtest CLI#
Before automating internet speed tests with PowerShell, the Ookla Speedtest CLI must be installed. Here’s how to do it on various operating systems:
Windows Installation#
-
Download and Install Winget:
- Winget is pre-installed on Windows 11 versions. If you get an error when you type
winget
in PowerShell, follow these steps to install it. - Visit the Winget GitHub releases page .
- Download and open the
Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
file and follow the on-screen instructions. - After installation, close and reopen the PowerShell window. Type
winget
to verify the installation.
- Winget is pre-installed on Windows 11 versions. If you get an error when you type
-
Install Speedtest CLI Using Winget:
winget install --id=Ookla.Speedtest.CLI -e
macOS, Ubuntu/Debian, Fedora/CentOS, FreeBSD Installation#
(Include detailed installation instructions for these operating systems)
Creating the Speed Test Script on Windows#
We will guide you through creating a PowerShell script step-by-step to automate internet speed tests and save the results.
Step 1: Run the Speedtest Command#
Run the speedtest
command in PowerShell to see the output:
speedtest
Step 2: Analyze the Output#
Understand the Output:
- The output will display key metrics like download and upload speeds, latency, and server details.
Speedtest by Ookla
Server: Switch Inc. - City, State (id: 14553)
ISP: TELUS
Idle Latency: 5.58 ms (jitter: 1.60ms, low: 5.14ms, high: 9.06ms)
Download: 90.75 Mbps (data used: 98.5 MB)
41.81 ms (jitter: 10.30ms, low: 13.46ms, high: 344.05ms)
Upload: 69.28 Mbps (data used: 78.1 MB)
345.08 ms (jitter: 86.85ms, low: 23.80ms, high: 624.29ms)
Packet Loss: 0.0%
Result URL: https://www.speedtest.net/result/c/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
Step 3: Getting Creative#
- Now, let's see what else we can do. Looking at [Speedtest commands](https://gist.github.com/itsChris/6f7a5d59b408f0cb774bf2570137a0ef#file-speedtest-cli-by-ookla-md)
You can also view this locally by running `speeedtest -h` command
notice the `-f format_type –form` for output formats. We want to work with csv so we can combine multiple outputs into the same file for over time comparison
Step 3: Create a Date Folder and Save Results#
Create a folder with the current date and save the speed test results in CSV format: Creating a Date-Specific Folder:
$dateFolder = (Get-Date).ToString('yyyy-MM-dd')
New-Item -Path $dateFolder -ItemType Directory
speedtest --format=csv | Out-File "$dateFolder\speedtest.csv"
Step 4: Accumulate and Display Multiple Results#
Run the test multiple times and import the CSV data to view it as a table:
Import-Csv "$dateFolder\speedtest.csv" | Format-Table
Step 5: Automate Daily Speed Tests#
Combine all steps into a script for daily automation:
$dateFolder = (Get-Date).ToString('yyyy-MM-dd')
New-Item -Path $dateFolder -ItemType Directory -Force
speedtest --format=csv | Out-File "$dateFolder\speedtest.csv"
Considerations for Accurate Testing#
Explain how to ensure accurate test results for discussions with ISPs.
Analyzing Your Speed Test Data#
Describe how to use the accumulated data for understanding internet speed trends.
Next Steps#
- Explore Advanced Networking Scripts : Dive deeper into PowerShell for networking.
- Troubleshooting Network Issues : Learn how to troubleshoot common network problems using PowerShell.
With this PowerShell script, you’re well-equipped to keep track of your internet speed and network health!