Test your Internet connection using PowerShell

This script gives you detailed information about the speed of your Internet connection (down speed, upload speed, packetloss, latency…etc), so you can get an idea if you’re having problems with your Internet connection.

The script uses the speedtest.exe application from speedtest.net to generate the result.

the script downloads the application directly from speedtest.net, extracts the file into C:\temp and then displays the result.

Here’s the result :

Powershell : speedtest result

and here’s the script :

 # Create temp folder under C:
$Dir = "C:\temp\" 
if((Test-Path $Dir) -eq $false)
{
    New-Item -ItemType Directory -Path $Dir -erroraction SilentlyContinue | Out-Null
}

# Giving Name to file to be downloaded
$Download = $Dir + "speedtest.zip"

# Download the SpeedTest file from official website
Invoke-WebRequest 'https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-win64.zip' -OutFile $Download

# Unzip file
Expand-Archive $Download -DestinationPath "C:\temp\speedtest\"

# Execute speed test
$Speedtest = & "C:\temp\speedtest\speedtest.exe" --format=json --accept-license --accept-gdpr
Start-Sleep 3
# Convert result to Json
$Speedtest = $Speedtest | ConvertFrom-Json

# Create New Object SpeedObject
[PSCustomObject]$SpeedObject =[ordered] @{
    downloadspeed = [math]::Round($Speedtest.download.bandwidth / 1000000 * 8, 2)
    uploadspeed   = [math]::Round($Speedtest.upload.bandwidth / 1000000 * 8, 2)
    packetloss    = [math]::Round($Speedtest.packetLoss)
    Latency       = [math]::Round($Speedtest.ping.latency)
    isp           = $Speedtest.isp
    ExternalIP    = $Speedtest.interface.externalIp
    InternalIP    = $Speedtest.interface.internalIp
    UsedServer    = $Speedtest.server.host
    URL           = $Speedtest.result.url
    Jitter        = [math]::Round($Speedtest.ping.jitter)
    
}

Clear-Host
write-host
$SpeedObject 

Thanks

Aymen EL JAZIRI (Microsoft MVP)
Aymen EL JAZIRI (Microsoft MVP)

Hi, I’m Aymen El Jaziri , a passionate System Administrator and Microsoft MVP, with years of hands-on experience in managing and securing modern IT infrastructures.
This blog is where I share technical guides, automation scripts, product reviews, and real-world solutions that help IT professionals simplify their day-to-day work and stay ahead in a fast-evolving cloud ecosystem.
Whether you’re here to troubleshoot an issue, improve your automation game, or learn new best practices , welcome in my blog !
Let’s build a stronger, smarter IT community together.
Feel free to connect with me on LinkedIn for more content, discussions, or collaboration opportunities.

Thanks

Aymen

Articles: 154