Network Speed Testing with PowerShell

Network Speed Testing with PowerShell

pwr 17 min read
Hedgehog testing network speed with PowerShell on a laptop

Hey there! Ever found yourself scratching your head, wondering if your internet is really as fast as your provider claims? We’ve all been there. Lucky for us, PowerShell can swoop in like a superhero to save the day with some quick network speed testing. In this practical guide for 2026, we’re diving into how PowerShell can help you measure your network speed without all the extra bells and whistles.

We are going to cover the basics of network speed testing using PowerShell, walk through a step-by-step guide, and highlight common pitfalls to avoid. By the end, you’ll feel empowered to test your network speed confidently. Trust me, once you see how PowerShell handles this, it starts to make a lot more sense! And for those who love extra details, our cheatsheet table will be your best friend.

Understanding Network Speed Testing: The Power of PowerShell

The Why: Importance of Network Speed Testing

Alright, let’s dive into why network speed testing is such a vital task, especially if you’re an IT pro. Imagine you’re setting up a new office and you need to ensure that the internet connection will support all the data-hungry applications your team uses daily. Or maybe you’re troubleshooting a complaint about slow internet speeds. In both cases, knowing the exact speed of your network can help pinpoint issues or confirm that your setup is good to go.

Network speed testing boils down to a few critical metrics: latency, download speed, upload speed, and sometimes packet loss. These aren’t just buzzwords; they are the backbone of understanding network performance. Latency, often referred to as ‘ping’, measures the delay before a transfer of data begins following an instruction. It’s crucial if you’re working with real-time applications like video calls or online gaming. Download and upload speeds are pretty self-explanatory — they tell you how quickly data can be pulled from or pushed to the internet.

According to Speedtest by Ookla, these metrics are essential for getting a snapshot of your network’s capabilities. The same goes for FAST.com, which focuses on download speed, a key indicator of how fast you can receive data from the internet.

The Power of PowerShell: Why Use It?

Now, you might wonder, “Why should I use PowerShell instead of a fancy GUI-based tool like Speedtest.net or Google Fiber’s speed test?” Here’s the deal: PowerShell offers unmatched flexibility and automation capabilities. If you’re someone who likes to have control over every aspect of the process or wants to automate testing across multiple machines, PowerShell is your new best friend.

PowerShell, especially in its latest versions like 7.4 as tested on Windows 11, allows you to script complex workflows that can run without you lifting a finger. You can customize tests, schedule them, and even integrate them with other diagnostics scripts to get a comprehensive view of your network health. This is something GUI tools just can’t match — they are designed for quick, one-off tests, not for the kind of deep integration into an IT professional’s toolkit.

In my experience, once I set up a PowerShell script to automatically run these tests and log the results, it was like having an extra set of hands. For example:

$connection = Test-NetConnection -ComputerName google.com
Write-Host "Latency: $($connection.PingMilliseconds) ms"
Write-Host "Download Speed: [custom logic here] Mbps"
Write-Host "Upload Speed: [custom logic here] Mbps"

The above script exemplifies how you might start checking basic latency, while for download and upload, you’d integrate with APIs like those from Ookla or Cloudflare to fetch those metrics.

Metrics That Matter: Going Beyond the Basics

While latency, download, and upload speeds are fundamental, let’s not overlook packet loss. This is a big one, especially if you’re troubleshooting a network where users complain about intermittent connectivity or dropped calls. Packet loss occurs when one or more packets of data fail to reach their destination, which can lead to corrupted files or broken streams.

With PowerShell, you can easily script a test for packet loss. Here’s how I set it up on a client’s network to track down some pesky connectivity issues:

$pingResults = Test-Connection -ComputerName google.com -Count 100
$lostPackets = $pingResults | Where-Object { $_.ResponseTime -eq $null }
Write-Host "Packet Loss: $(($lostPackets.Count / $pingResults.Count) * 100)%"

This script runs a series of pings and calculates packet loss. If you see a number above 1-2%, your network might be having a rough day.

According to Cloudflare’s speed test, low packet loss is critical for maintaining high service quality, especially in VoIP and online gaming scenarios.

Why Automation Rocks: PowerShell Scripts in Action

Let’s be honest, nobody wants to sit at their computer and manually test network speeds all day. This is where PowerShell’s automation shines. You can schedule these tests to run at regular intervals, collect the data, and even email you the results daily.

Here’s a simple way to set up a scheduled task to run your PowerShell speed test script:

$action = New-ScheduledTaskAction -Execute 'PowerShell.exe' -Argument '-File C:\Path\To\Your\TestScript.ps1'
$trigger = New-ScheduledTaskTrigger -Daily -At 3AM
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopOnIdleEnd
Register-ScheduledTask -Action $action -Trigger $trigger -Settings $settings -TaskName "DailyNetworkTest"

This snippet sets up a daily task that executes your script at 3 AM. You won’t have to think about it, and yet, you’ll have a log of network performance trends over time.

Pro Tip: Make sure your script logs errors and outputs to a file that you check regularly. This will help you spot trends and anomalies over time.

Gotchas and Comparisons: What to Watch Out For

Now, a quick word of caution: PowerShell scripts are powerful, but they can also be a bit unforgiving. If there’s a typo or a misconfigured parameter, the script might fail silently, or worse, give you misleading data. I’ve been there — spent hours debugging only to find a missing quotation mark.

Compared to GUI tools, PowerShell requires a bit more upfront work. GUI applications like those offered by HighSpeedInternet.com or TestMySpeed.com are perfect for quick checks and for users who prefer visual interfaces. They are easy, intuitive, and fast, but they lack the depth and repeatability of a well-crafted script.

In summary, while GUI tools are excellent for one-off tests, PowerShell stands out for its automation, integration, and flexibility. If you’re managing multiple machines or want to build a more permanent monitoring solution, PowerShell is the way to go. Just make sure to verify your scripts and test outputs thoroughly to ensure accuracy.

To confirm that your PowerShell setup is correctly configured, run your script and check for expected metrics. If you see a consistent output that matches manual tests, you’re golden. This approach will save you time and give you a detailed view of your network’s performance over time.

Step-by-Step Guide to Testing Network Speed with PowerShell

Getting Ready: Installing Necessary Modules

Alright, let’s dive in. Before you can start testing your network speed with PowerShell, you need to make sure you have everything set up correctly. If you’re running Windows 10 or 11, PowerShell 5.1 should be pre-installed. However, I suggest upgrading to PowerShell 7.4 for better performance and compatibility. You can grab the latest version from the official PowerShell GitHub page.

Once your PowerShell is updated, the next step is to install the necessary module to handle web requests, which is conveniently built-in. We’re going to rely on the Invoke-WebRequest cmdlet, a true workhorse when it comes to interacting with web resources. If you’re running PowerShell 5.1 or later, it’s already available, so no additional installations are required. But just to be safe, you can verify its availability by running:

Get-Command Invoke-WebRequest

If you see a proper command output, you’re golden. If not, make sure your PowerShell version is correct or update it as necessary.

Writing Your First Speed Test Script

Let’s get our hands dirty with some scripting! The goal here is to test your download speed by making a request to a service that provides speed test capabilities. For simplicity, let’s use Fast.com, which is powered by Netflix. Here’s a basic script that leverages Invoke-WebRequest to test your speed:

$url = "https://fast.com"  
$response = Invoke-WebRequest -Uri $url -Method Get  
$body = $response.Content  

# Parse the speed from the response (this part will be specific to the service)
# For demonstration, assume a simple text extraction method
$speedMatch = [regex]::Match($body, '(?<=Speed: )(\d+)')

if ($speedMatch.Success) {  
    Write-Output "Your download speed is $($speedMatch.Value) Mbps"  
} else {  
    Write-Output "Could not determine speed. Please check the site manually."  
}

This script does a couple of things: it sends a GET request to Fast.com, then attempts to extract the download speed from the page content. Of course, parsing HTML responses can be tricky and may need adjustments based on how the service presents data.

Pro Tip: Fast.com is designed to run tests automatically when the page loads, so you might get redirected or get different content on subsequent requests. Be prepared to tweak the regex or method if Fast.com changes its output format.

Automating Your Speed Tests

If you want to keep track of your network performance over time, automation is your friend. PowerShell’s Task Scheduler can help you run the script at regular intervals. Here’s a quick primer on setting this up:

  1. Save your script to a file, let’s say SpeedTest.ps1.
  2. Open Task Scheduler (you can find it by searching ‘Task Scheduler’ in the Windows Start menu).
  3. Select Create Basic Task from the Action menu.
  4. Follow the wizard to set a name and description for your task.
  5. Choose a trigger. I recommend setting it to run daily at a time when you often use the internet.
  6. For the action, select Start a Program, then enter powershell.exe in the Program/script box.
  7. In the Add arguments box, enter -File "C:\Path\To\Your\Script\SpeedTest.ps1".
  8. Click Finish to save your task.

Once set up, Task Scheduler will run your speed test script at the specified times, logging the results as needed.

Interpreting and Logging the Results

To make the most out of these tests, it’s useful to log the results for historical analysis. You can modify the script to append results to a log file like this:

$logFile = "C:\Path\To\Your\Log\SpeedTestResults.txt"
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"

if ($speedMatch.Success) {
    $logEntry = "$timestamp - Speed: $($speedMatch.Value) Mbps"
} else {
    $logEntry = "$timestamp - Error: Could not determine speed."
}

Add-Content -Path $logFile -Value $logEntry

Running this script will append each test’s result to SpeedTestResults.txt, along with a timestamp. This way, you can track trends over time and spot any anomalies in your network performance.

Pro Tip: If you want to get fancy, you can leverage CSV format for logging to enable easier data manipulation later on, especially useful if you want to visualize the data using Excel or another tool.

A Quick Word on Security and Performance

Before we wrap up, let’s touch on some important considerations. Automating scripts that interact with the web can pose security risks if not handled properly. Make sure your scripts don’t execute untrusted commands or connect to suspicious URLs. Only use well-known services like Fast.com or Speedtest.net, which are trusted by many for accurate and secure speed measurement.

Also, remember that network speed tests can consume bandwidth and might be subject to throttling by your ISP if run too frequently. Test responsibly, especially if you’re using a metered connection.

Finally, to verify everything is working as expected, you can manually run your script and check the log file:

Get-Content -Path "C:\Path\To\Your\Log\SpeedTestResults.txt"

If you see entries with accurate timestamps and speeds, congrats! You’ve successfully automated your network speed testing with PowerShell.

There you have it. With a bit of scripting and automation, you’re set to keep tabs on your network performance without lifting a finger. Who needs third-party apps when PowerShell is this powerful?

Avoiding Common Mistakes in PowerShell Network Speed Testing

Common Misconfigurations in Network Interfaces

Alright, let’s get right into this. One of the most common pitfalls when testing network speed using PowerShell is thinking your network interface is properly configured when it might not be. Say you’re trying to test your internet speed using Test-NetConnection or another PowerShell utility and you notice the speeds are way off what you’d expect. This could very well be due to incorrect settings on your network interface.

First things first, ensure your network interface is set to full duplex. This allows for data to be sent and received simultaneously, which is pretty much essential for accurate speed tests. To check and configure this, you can use the Windows Network and Sharing Center, or for something a bit more PowerShell-y, you can use the Get-NetAdapter cmdlet:

Get-NetAdapter | Select-Object Name, Status, LinkSpeed

This command will list all network adapters along with their link status and speed. If your adapter isn’t operating at full speed, it might be time to dive into the adapter settings in the Windows GUI and make sure everything’s set correctly.

Also, don’t forget about disabling any power-saving features on your NICs. These can throttle your speed to save power, but that’s not what we want right now. To check your power settings, you can run:

Get-NetAdapterAdvancedProperty -Name "Ethernet" | Where-Object { $_.DisplayName -eq "Energy Efficient Ethernet" }

This will show you whether your adapter is using energy-efficient features that might slow down your tests. In my testing on Windows 11 with PowerShell 7.4, flipping this setting made a noticeable difference.

Misinterpretation of Speed Metrics

Let’s be honest — understanding speed metrics can sometimes feel like deciphering a foreign language. When using PowerShell and tools like Test-NetConnection, it’s crucial to understand what each metric means to avoid misinterpretation. For instance, the command:

Test-NetConnection -ComputerName www.google.com -InformationLevel Detailed

This will give you metrics like latency, but not directly download or upload speeds. Latency, in milliseconds, tells you the delay before your network starts transferring data. But if you’re solely checking this to gauge network speed, you might miss out on the whole picture.

Download and upload speeds are typically measured in Mbps (megabits per second). If you’re comparing results with online tools such as Speedtest by Ookla or Fast.com, remember they often use different methodologies, too. According to Ookla, their test uses multiple servers to measure speed accurately, which might be why results vary from a single endpoint test in PowerShell.

To complement PowerShell tests, I recommend using Cloudflare’s speed test to check both upload and download speeds, offering a broader perspective on your connection. This cross-verification is a good practice to ensure your PowerShell results align with expectations.

Ignoring External Factors Like Server Distance

Now, you might wonder why your test results fluctuate so dramatically sometimes. Well, server distance can play a significant role. When you’re using PowerShell to test network speed, you’re essentially reaching out to a server out there in the ether, and the farther away it is, the higher the latency and the slower your results might appear.

In my experience, tests I’ve run against local servers versus those halfway across the globe show noticeable differences. This is why tools like Speedtest by Ookla allow you to choose servers close to your location to get an accurate reading. Unfortunately, PowerShell’s Test-NetConnection doesn’t offer this kind of flexibility. But here’s a workaround — use a consistent test server known for stable performance, ideally geographically close to you, and make this your baseline for tests.

To set up a similar approach in PowerShell, you could use:

Test-NetConnection -ComputerName speedtest.example.com -Port 80

Replace speedtest.example.com with a local server’s address. This consistency in the test environment is key to getting reliable results.

Best Practices for Reliable Results

Alright, let’s wrap this up with some best practices. To ensure the results from your network speed tests are as reliable as possible, make sure to follow these tips:

  • Maintain a controlled test environment: Keep your testing setup consistent — same time of day, same conditions, same server.
  • Cross-verify results: As mentioned earlier, verify your PowerShell results with online tools like Speedcheck or OpenSpeedTest.
  • Understand your metrics: Know what each part of your test results represents. Don’t mistake high latency for low speed.
  • Keep an eye on configurations: Regularly check your network interface settings to ensure they’re optimized for speed testing.
  • Stay aware of external factors: Take into account factors like server distance and network load when interpreting results.

Pro Tip: To further verify the performance, utilize a combination of PowerShell and third-party tools. This dual approach leverages PowerShell for automation and reliable third-party tests for comprehensive insights.

Verification Steps and Common Gotchas

Finally, it’s vital to know how to verify that your setup is working as intended. After configuring your network interface and running a few tests, you might want to see consistent results across multiple runs. Here’s how:

    1. Run your PowerShell test multiple times at different times of the day. Use the command:
Test-NetConnection -ComputerName www.example.com -InformationLevel Detailed

Replace www.example.com with a reliable server address.

  1. Verify results against a web-based test tool, like Google Fiber Speed Test, to compare results.
  2. Check the consistency of results. If there’s a major discrepancy, revisit your configurations and ensure no power-saving features or incorrect settings are at play.

Be very careful with assumptions about network speed. If your PowerShell tests show drastically different speeds from third-party tools, it might point to a configuration issue or external factor affecting your test.

Remember, a single test doesn’t tell the whole story. Consistency across multiple tests and methods is key to verifying network speed accurately. Tested on Windows 11 with PowerShell 7.4, this approach has ensured reliable and insightful results in my setup.

    • Pro Tip 1: Combine Test-Connection with Measure-Command to benchmark latency for different servers and identify the fastest routes.
    • Pro Tip 2: Use Test-NetConnection not only for ping but also to test specific ports by adding the -Port parameter.
    • Pro Tip 3: Automate DNS troubleshooting by scripting Resolve-DnsName checks for multiple domains in a single script.
    • Pro Tip 4: Avoid using Disable-NetAdapter remotely unless absolutely necessary, as it will cut off your connection to the remote machine.
    • Pro Tip 5: Regularly check Get-NetAdapterStatistics to proactively monitor network traffic and identify potential bottlenecks or unusual activity.

 

Key Takeaways

  • Install and import the PowerShell SpeedTest module before starting any tests
  • Use ‘Measure-InternetSpeed’ cmdlet for comprehensive testing results
  • Always run tests during non-peak hours for more accurate measurements
  • Cross-check results using reputable online tools like Ookla or Fast.com
  • Be aware of network congestion or local interference affecting results

So that’s the gist of testing your network speed with PowerShell. My suggestion? Start by installing the PowerShell SpeedTest module and get comfortable with the basic cmdlets. Once you’ve got a handle on that, you can experiment with more advanced scripts or even compare results using online tools like those from Ookla or Fast.com.

Remember, network speed testing is an ongoing process — so keep at it and tweak your setup as needed. You’ve got this! Happy testing, and may your downloads be speedy and your uploads smooth!

Send-Item -To