Last active
March 20, 2025 20:00
-
-
Save azurekid/ca641c47981cf8074aeaf6218bb9eb58 to your computer and use it in GitHub Desktop.
PowerShell script to download DevOps Extensions from the marketplace as a local file
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
[CmdletBinding()] | |
param | |
( | |
[Parameter(Mandatory = $true)] | |
[string] $Publisher, | |
[Parameter(Mandatory = $true)] | |
[string] $ExtensionName, | |
[Parameter(Mandatory = $true)] | |
[ValidateScript( { | |
If ($_ -match "^([0-9]+\.[0-9]+\.[0-9]+)$") { | |
$True | |
} | |
else { | |
Throw "$_ is not a valid version number. Version can only contain digits" | |
} | |
})] | |
[string] $Version, | |
[Parameter(Mandatory = $true)] | |
[string] $OutputLocation | |
) | |
Set-StrictMode -Version Latest | |
$ErrorActionPreference = "Stop" | |
Write-Output "Publisher: $($Publisher)" | |
Write-Output "Extension name: $($ExtensionName)" | |
Write-Output "Version: $($Version)" | |
Write-Output "Output location $($OutputLocation)" | |
$baseUrl = "https://$($Publisher).gallery.vsassets.io/_apis/public/gallery/publisher/$($Publisher)/extension/$($ExtensionName)/$($Version)/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage" | |
$outputFile = "$($Publisher)-$($ExtensionName)-$($Version).visx" | |
if (Test-Path $OutputLocation) { | |
try { | |
Write-Output "Retrieving extension..." | |
[uri]::EscapeUriString($baseUrl) | Out-Null | |
Invoke-WebRequest -Uri $baseUrl -OutFile "$OutputLocation\$outputFile" | |
} | |
catch { | |
Write-Error "Unable to find the extension in the marketplace" | |
} | |
} | |
else { | |
Write-Output "The Path $($OutputLocation) does not exist" | |
} |
l-logan-777
commented
Mar 8, 2025
via email
Hi,
Wanted to let you know that I have figured it out. It was not an error in the code. After debugging it a bit, that it was a network proxy issue at work. It worked perfectly at home.
Thanks for responding.
…--Lee
________________________________
From: Rogier Dijkman ***@***.***>
Sent: Saturday, March 8, 2025 12:42 AM
To: azurekid ***@***.***>
Cc: Mention ***@***.***>
Subject: Re: azurekid/get-extensions.ps1
WARNING: This email originated from outside of Cornerstone Defense. Treat with EXTREME CAUTION!
DO NOT CLICK LINKS OR OPEN ATTACHMENTS unless you are ABSOLUTELY CERTAIN of the sender.
NEVER provide your username or password.
@azurekid commented on this gist.
________________________________
I am trying to use this and for whatever reason it keeps giving me the error: Unable to find the extension in marketplace. Our company started having issues with some of their downloads as well last month. cmdlet DL_ext3.ps1 at command pipeline position 1 Supply values for the following parameters: Publisher: Red Hat ExtensionName: redhat.ansible Version: 25.2.0 OutputLocation: C:\Users\fm815f Publisher: Red Hat Extension name: redhat.ansible Version: 25.2.0 Output location C:\Users\fm815f Retrieving extension... DL_ext3.ps1: Unable to find the extension in the marketplace
Any help would be greatly appreciated. Thanks
Hi, and happy weekend @l-logan-777<https://github.com/l-logan-777>
I will take a look at it and come back to you later this weekend
—
Reply to this email directly, view it on GitHub<https://gist.github.com/azurekid/ca641c47981cf8074aeaf6218bb9eb58#gistcomment-5474767> or unsubscribe<https://github.com/notifications/unsubscribe-auth/BQFGTWBUUHXPIZCR7T6NVGT2TKNNHBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTAMBTGQ3DGMJXU52HE2LHM5SXFJTDOJSWC5DF>.
You are receiving this email because you were mentioned.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
It is quiet some time ago when I wrote this script.
If would like to see any features added, please let me know :-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment