How to list available Azure VM images using PowerShell
In this short post, I will show you how you can retrieve the current available VM images from Azure using Powershell.
To get started, you will have to connect to Azure using PowerShell by running the following.
You will be prompted for your Username and Password
To get a list of all the available Images in your chosen region, run the following.
- List the available publishers in your region
$locName="southafricanorth" Get-AzVMImagePublisher -Location $locName |Select PublisherName
- From the list of Publishers select your publisher and run the below, I will select “MicrosoftWindowsServer” as my offer for this example.
$pubName="MicrosoftWindowsServer" Get-AzVMImageOffer -Location $locName -PublisherName $pubName | Select Offer
- Now that we have a list of available Offers for the Publisher “MicrosotWindowsServer”, let’s go ahead and list the available Skus. I will select “WindowsServer” as the Offer.
$offerName="WindowsServer" Get-AzVMImageSku -Location $locName -PublisherName $pubName -Offer $offerName | Select Skus
- So, now we can see the available Skus for “WindowsServer”, we now need to look at the available Images for the different Skus. I will select “2019-Datacenter” as the Sku, so lets see which images are available for this Sku.
As we can see in the images below, these are the different images available for “Windows Server 2019” which is available in the selected region.
If you already know which Publisher and Offer you would like to view, then you can run the script as follow.
$locName="southafricanorth" $pubName="MicrosoftWindowsServer" $offerName="WindowsServer" $skuName="2019-Datacenter" Get-AzVMImage -Location $locName -PublisherName $pubName -Offer $offerName -Skus $skuname
And that’s how you can quickly retrieve a list of all the available VM images and Publishers in your Azure Region using PowerShell.