Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeppPenner/a6cf9b328ed7be8e780486e7f0121782 to your computer and use it in GitHub Desktop.
Save SeppPenner/a6cf9b328ed7be8e780486e7f0121782 to your computer and use it in GitHub Desktop.
Nov 2018 - PowerShell script to download all NuGet packages
$indexClient = new-object system.net.webclient
$jsonIndex=$indexClient.DownloadString("https://api.nuget.org/v3/catalog0/index.json") | ConvertFrom-Json
for ($h=0; $h -lt $jsonIndex.items.Length; $h++) {
$web_client = new-object system.net.webclient
$jsonObj=$web_client.DownloadString($jsonIndex.items[$h].'@id') | ConvertFrom-Json
for ($i=0; $i -lt $jsonObj.items.Length; $i++) {
$package = $jsonObj.items[$i]."nuget:id" + "/" + $jsonObj.items[$i]."nuget:version"
$web_client.DownloadFile("https://www.nuget.org/api/v2/package/" + $package, ("C:\Nuget\" + $jsonObj.items[$i]."nuget:id" + "." + $jsonObj.items[$i]."nuget:version" + ".nupkg"))
"Processing: " + ($h + 1) + " of " + $jsonIndex.count + " ---- " + ($i + 1) + " of " + $jsonObj.count + " - " + $jsonObj.items[$i]."nuget:id" + "." + $jsonObj.items[$i]."nuget:version"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment