$webClient = New-Object System.Net.WebClient $webClient.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials Some web servers block scripts with default user agents:
# PowerShell 2.0 - Basic File Download $url = "https://www.example.com/software/update.msi" $output = "$pwd\update.msi" $webClient = New-Object System.Net.WebClient $webClient.DownloadFile($url, $output) powershell 2.0 download file
These operating systems ship with as the default or maximum available version. If you find yourself needing to download a file (a script, an update, or configuration data) using PowerShell 2.0, you cannot rely on the sleek Invoke-WebRequest (introduced in version 3.0) or Invoke-RestMethod . $webClient = New-Object System
Write-Host "Download completed to: $output" Legacy systems demand legacy solutions—but you can still
$wc = New-Object System.Net.WebClient [System.Net.ServicePointManager]::SecurityProtocol = 3072 # Enable TLS 1.2 $wc.DownloadFile("https://your.url/file.zip", "C:\path\file.zip") Use this technique wisely, test your SSL settings, and always plan an upgrade path away from PowerShell 2.0. Legacy systems demand legacy solutions—but you can still make them work safely and efficiently. Have a legacy automation challenge? Let us know in the comments below. For more PowerShell 2.0 tips, check out our guide on "Parsing XML without Select-Xml" and "Working with COM objects in PS 2.0."
Force .NET to use TLS 1.2 before downloading:
# PowerShell 2.0 - BITSAdmin download $url = "https://www.example.com/file.zip" $output = "C:\downloads\file.zip" bitsadmin /transfer "MyDownloadJob" /download /priority normal $url $output Check result if (Test-Path $output) Write-Host "Download successful via BITS" else Write-Host "Download failed"