View all VM versions and SKUS at once on Microsoft Azure Powershell

I was trying to create a VM with Azure Powershell. I was wondering what and where to found the VM versions and names.

Whith this script, you can have a list of all available publishers, offers, skus, and versions of virtual machines. This aims to simplify your Azure deployment, using powershell scripts to create your environment.

You will need Azure Powershell and an active connection to your Azure subscription.

You can write a star “*” to show all Publishers and Offers/SKUS/Versions.

An example of the output :


The script

$ErrorActionPreference = 'SilentlyContinue'
$ProgressPreference = "SilentlyContinue"
$WarningPreference = "SilentlyContinue"

#We Get the search data
$search = ""
while($search -like ""){
	$search = Read-Host "Please write you desired search (Example : MicrosoftWindowsServer) :"

$Location = "West Europe" #You can set a different location here
#To see available locations on azure :  Get-AzureRmLocation | FT DisplayName

$Publishers = Get-AzureRMVMImagePublisher -Location $Location | ?{$_.PublisherName -like "*$search*"} | Select PublisherName

foreach ($Publisher in $Publishers){
	$offers = Get-AzureRMVMImageOffer -Location $Location -Publisher $Publisher.PublisherName | Select Offer
	Write-Host "PUBLISHER|"$Publisher.PublisherName -foregroundcolor "Green"
	foreach ($offer in $offers){
		Write-Host "OFFER    |----  "$offer.offer -foregroundcolor "Yellow"
		$SKUs = Get-AzureRMVMImageSku -Location $Location -Publisher $Publisher.PublisherName -Offer $offer.offer | Select Skus
		foreach ($SKU in $SKUs){
			Write-Host "SKU      |--------  "$SKU.skus -foregroundcolor "magenta"
			$VMImages = Get-AzureRMVMImage -Location $Location -Publisher $Publisher.PublisherName -Offer $offer.offer -Sku $SKU.skus | Select Version
			foreach ($VMImage in $VMImages){
				Write-Host "VMImage  |--------  "$VMImage.version -foregroundcolor "cyan"




Leave a Reply

Your email address will not be published. Required fields are marked *