Skip to content

Instantly share code, notes, and snippets.

@MiloszKrajewski
Last active October 21, 2016 10:19
Show Gist options
  • Save MiloszKrajewski/86f854fa0ed411678dea219523a56108 to your computer and use it in GitHub Desktop.
Save MiloszKrajewski/86f854fa0ed411678dea219523a56108 to your computer and use it in GitHub Desktop.
param([String]$url, [String]$path="")
# It is a poor man's cURL, but can be used to download cURL
# powershell -file download.ps1 -url https://dl.uxnr.de/build/curl/curl_winssl_cross_x64/curl-7.50.3/curl-7.50.3.zip
# powershell -file download.ps1 -url https://cdn.rawgit.com/martinrotter/7za/master/7za.exe
# NOTE: may require "Set-ExecutionPolicy RemoteSigned"
if ($path -eq "") {
$path = [System.IO.Path]::GetFileName($url)
}
if (test-path $path) {
write-host -fore yellow "Already exists: $path"
} else {
write-host -fore green "Downloading: $url"
$client = new-object Net.WebClient
$proxy = [System.Net.WebRequest]::DefaultWebProxy
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$client.Proxy = $proxy
$client.DownloadFile($url, $path)
write-host -fore green "Saved as: $path"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment