Last active
February 12, 2016 13:25
-
-
Save rheid/02e7954f9742afb002db to your computer and use it in GitHub Desktop.
Get-AzureResourceGroupGalleryTemplate from new Azure REST Interface
This file contains 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
# Retrieve all available items | |
$allGalleryItems = Invoke-WebRequest -Uri "https://gallery.azure.com/Microsoft.Gallery/GalleryItems?api-version=2015-04-01&includePreview=true" | ConvertFrom-Json | |
# Get all items published by Microsoft | |
$allGalleryItems | Where-Object { $_.PublisherDisplayName -eq "Microsoft" } | |
# Get all gallery items with "SQL" in the description | |
$allGalleryItems | Where-Object { $_.Description -match "SQL" } | |
# Save default template for all items under directory "C:\Templates" | |
$allGalleryItems | Foreach-Object { | |
$path = Join-Path -Path "C:\templates" -ChildPath $_.Identity | |
New-Item -type Directory -Path $path | |
$_.Artifacts | Where-Object { $_.type -eq "template" } | ForEach-Object { | |
$templatePath = Join-Path -Path $path -ChildPath ( $_.Name + ".json" ) | |
(Invoke-WebRequest -Uri $_.Uri).Content | Out-File -FilePath $templatePath | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment