try # Get file size for progress calculation $client.OpenRead($url) finally if ($stream) $stream.Close() if ($fileStream) $fileStream.Close() $client.Dispose()
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 Note: If Tls12 enum doesn't exist (rare in PS2.0), use the integer value:
PowerShell 2.0 lacks many of the convenience cmdlets we take for granted today. There is no Invoke-WebRequest (introduced in v3), no curl alias, and no WebClient.DownloadFileAsync syntactic sugar.
[Parameter(Mandatory=$false)] [int]$TimeoutSeconds = 60,
# Set timeout (in milliseconds) $webClient.Timeout = $TimeoutSeconds * 1000
try # Get file size for progress calculation $client.OpenRead($url) finally if ($stream) $stream.Close() if ($fileStream) $fileStream.Close() $client.Dispose()
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 Note: If Tls12 enum doesn't exist (rare in PS2.0), use the integer value: powershell 2.0 download file
PowerShell 2.0 lacks many of the convenience cmdlets we take for granted today. There is no Invoke-WebRequest (introduced in v3), no curl alias, and no WebClient.DownloadFileAsync syntactic sugar. try # Get file size for progress calculation $client
[Parameter(Mandatory=$false)] [int]$TimeoutSeconds = 60, no curl alias
# Set timeout (in milliseconds) $webClient.Timeout = $TimeoutSeconds * 1000