In PowerShell 2.0, you cannot use common modern commands like Invoke-WebRequest (introduced in 3.0). Instead, you must use the class or the BITS module. Method 1: .NET WebClient (Recommended)
In enterprise environments, you often need credentials:
Register-ObjectEvent -InputObject $webClient -EventName DownloadFileCompleted -Action Unregister-Event -Force $webClient.Dispose()
Need a version for PowerShell 7? Just use Invoke-WebRequest -Uri $url -OutFile $path . But that's too easy, isn't it?
Some web servers block scripts with default user agents:
if ($webClient.Proxy -ne $null) $webClient.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials