|
|
|
@ -55,22 +55,22 @@ if($skip_certificate_validation){
|
|
|
|
|
$force = Get-Attr -obj $params -name "force" "yes" | ConvertTo-Bool
|
|
|
|
|
|
|
|
|
|
If ($force -or -not (Test-Path $dest)) {
|
|
|
|
|
$client = New-Object System.Net.WebClient
|
|
|
|
|
$webClient = New-Object System.Net.WebClient
|
|
|
|
|
if($proxy_url) {
|
|
|
|
|
$proxy_server = New-Object System.Net.WebProxy($proxy_url, $true)
|
|
|
|
|
if($proxy_username -and $proxy_password){
|
|
|
|
|
$proxy_credential = New-Object System.Net.NetworkCredential($proxy_username, $proxy_password)
|
|
|
|
|
$proxy_server.Credentials = $proxy_credential
|
|
|
|
|
}
|
|
|
|
|
$client.Proxy = $proxy_server
|
|
|
|
|
$webClient.Proxy = $proxy_server
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($username -and $password){
|
|
|
|
|
$client.Credentials = New-Object System.Net.NetworkCredential($username, $password)
|
|
|
|
|
$webClient.Credentials = New-Object System.Net.NetworkCredential($username, $password)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Try {
|
|
|
|
|
$client.DownloadFile($url, $dest)
|
|
|
|
|
$webClient.DownloadFile($url, $dest)
|
|
|
|
|
$result.changed = $true
|
|
|
|
|
}
|
|
|
|
|
Catch {
|
|
|
|
@ -89,7 +89,7 @@ Else {
|
|
|
|
|
$webRequest.Method = "GET"
|
|
|
|
|
[System.Net.HttpWebResponse]$webResponse = $webRequest.GetResponse()
|
|
|
|
|
|
|
|
|
|
$stream = New-Object System.IO.StreamReader($response.GetResponseStream())
|
|
|
|
|
$stream = New-Object System.IO.StreamReader($webResponse.GetResponseStream())
|
|
|
|
|
|
|
|
|
|
$stream.ReadToEnd() | Set-Content -Path $dest -Force -ErrorAction Stop
|
|
|
|
|
|
|
|
|
|