Skip to content

Instantly share code, notes, and snippets.

Created October 25, 2016 15:02
Show Gist options
  • Save anonymous/a47cd8229e8750bd6042bd7d156a64ac to your computer and use it in GitHub Desktop.
Save anonymous/a47cd8229e8750bd6042bd7d156a64ac to your computer and use it in GitHub Desktop.
#List all locations and select one
$location = (Get-AzureRmLocation).location | Out-GridView -Title "Select Azure location" -PassThru
#List all publishers and select one
$publisher = Get-AzureRmVMImagePublisher -Location $location | Select -ExpandProperty PublisherName | Out-GridView -Title "Select Publisher" -PassThru
#Get all offers for selected publisher
$Alloffers = @(Get-AzureRmVMImageOffer -Location $location -Publisher $publisher | Select -ExpandProperty Offer)
#Get all images for all skus of all ofers for the selected publisher
foreach ($Offer in $Alloffers) {
$Allskus = (Get-AzureRmVMImageSku -Location $location -Publisher $publisher -Offer $offer | Select -ExpandProperty Skus)
foreach ($sku in $Allskus) {
$Allimages += @(Get-AzureRmVMImage -Location $location -PublisherName $publisher -Offer $offer -Skus $sku)
}
}
#Wash and sort object
$Allversions = $Allimages | select Version,Skus,Offer,PublisherName | Sort-Object Skus
Write-Output $Allversions
#$Allversions | Export-Csv c:\temp\All-Images-Skus-Offer.csv
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment