Skip to content

Instantly share code, notes, and snippets.

Created October 25, 2016 15:02
Show Gist options
  • Select an option

  • Save anonymous/a47cd8229e8750bd6042bd7d156a64ac to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/a47cd8229e8750bd6042bd7d156a64ac to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Oct 25, 2016.
    23 changes: 23 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@

    #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