Last active
September 12, 2019 13:32
-
-
Save SteveH3032/16a0343858bdcd0ae321f0f599539af4 to your computer and use it in GitHub Desktop.
Nov 2018 - PowerShell script to download all NuGet packages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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
Running the script above in Powershell I get the following error: