Skip to content

Instantly share code, notes, and snippets.

@chrissie1
Created July 25, 2011 19:37
Show Gist options
  • Save chrissie1/1104983 to your computer and use it in GitHub Desktop.
Save chrissie1/1104983 to your computer and use it in GitHub Desktop.
# variables
$url = "http://packages.nuget.org/v1/Package/Download/Chocolatey/0.9.8.4"
$chocTempDir = Join-Path $env:TEMP "chocolatey"
$tempDir = Join-Path $chocTempDir "chocInstall"
if (![System.IO.Directory]::Exists($tempDir)) {[System.IO.Directory]::CreateDirectory($tempDir)}
$file = Join-Path $tempDir "chocolatey.zip"
# download the package
Write-Host "Downloading $url to $file"
$downloader = new-object System.Net.WebClient
if (!$downloader.Proxy.IsBypassed($url))
{
$cred = get-credential
$webclient = new-object System.Net.WebClient
$proxyaddress = $webclient.Proxy.GetProxy($url).Authority
Write-host "Using this proxyserver: " $proxyaddress
$proxy = New-Object System.Net.WebProxy($proxyaddress)
$proxy.credentials = $cred.GetNetworkCredential();
$downloader.proxy = $proxy
}
$downloader.DownloadFile($url, $file)
# unzip the package
Write-Host "Extracting $file to $destination..."
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($file)
$destinationFolder = $shellApplication.NameSpace($tempDir)
$destinationFolder.CopyHere($zipPackage.Items(),0x10)
@ferventcoder
Copy link

Line 14.... does this work without "http://10.6.76.20:8080" ?

@chrissie1
Copy link
Author

It now has no more reference to the server. It should just pick it up if you have it configured. I hope this works for NTML proxies too but not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment