News

Powershell script to test download ability

Slightly odd one this - we had a series of issues with a client who was using a number of Dell XPS laptops, with Windows 11 and USB3 <=> Ethernet adapters based on the Realtek chipset, where the large downloads kept failing. Worked fine over Wi-Fi and with USB adapters which did not use the Realtek chipset.

To test this out seriously we needed a script which attempted to download a large file and write the result to a log file. This is it.

 


# Script to run in Powershell to download test files of various sizes
# DKM 2023-04
# DKM 2023-07 added logging function
#
#
# Source files from http://xcal1.vodafone.co.uk/ - see which for alternatives
# http://212.183.159.230/1GB.zip
# http://212.183.159.230/100MB.zip
#
# Function to write log

$Logfile = "C:TempDownLoadTest_$env:computername.log"
function WriteLog
{
Param ([string]$LogString)
$Stamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
$LogMessage = "$Stamp $LogString"
Add-content $LogFile -value $LogMessage
}
# End of function to write log
# Run Dowload
$GetInfo = { 
Invoke-WebRequest -OutFile testfile.zip -Uri http://212.183.159.230/100MB.zip
#
# Write result to log
WriteLog "Downloaded…."
#
# Wait and then loop
Start-Sleep -Seconds 10
# "Files are successfully downloaded in $env:computername" | Out-File -FilePath C:TempFileDownLoadLog.txt –Append

#
.$GetInfo
}
&$GetInfo

 

and this is a typical log:

2023/07/25 18:46:05 Downloaded….
2023/07/25 18:47:45 Downloaded….
2023/07/25 18:49:23 Downloaded….
2023/07/25 18:51:02 Downloaded…

 

<< Go back to the previous page