Table of Contents
Understand marketplace images
The Azure marketplace includes many images that can be used to create a new VM. In this step, the PowerShell module is used to search the marketplace for other Windows images, which can also be used as a base for new VMs. This process consists of finding the publisher, offer, SKU, and optionally a version number to identify the image.
Find the VM Images in Azure
Before you begin, let’s connect to Microsoft Azure using PowerShell.
Use the Get-AzVMImagePublisher command to return a list of image publishers:
Get-AzVMImagePublisher -Location "EastUS"
Use the Get-AzVMImageOffer to return a list of image offers. With this command, the returned list is filtered on the specified publisher named MicrosoftWindowsServer:
The results will look something like this example:
Get-AzVMImageOffer `
-Location "EastUS" `
-PublisherName "MicrosoftWindowsServer"
Offer PublisherName Location Id
----- ------------- -------- --
windows-10-1809-vhd-server-prod-stage MicrosoftWindowsServer eastus /Subscriptions/089d4ee9-0b8d-4bac-ab78-c12...
windows-10-1809-vhd-sf-server-prod-stage MicrosoftWindowsServer eastus /Subscriptions/089d4ee9-0b8d-4bac-ab78-c12...
windows-cvm MicrosoftWindowsServer eastus /Subscriptions/089d4ee9-0b8d-4bac-ab78-c12...
windows-server-2012-vhd-server-prod-stage MicrosoftWindowsServer eastus /Subscriptions/089d4ee9-0b8d-4bac-ab78-c12...
WindowsServer MicrosoftWindowsServer eastus /Subscriptions/089d4ee9-0b8d-4bac-ab78-c12...
windowsserver-gen2preview MicrosoftWindowsServer eastus /Subscriptions/089d4ee9-0b8d-4bac-ab78-c12...
windowsserver-previewtest MicrosoftWindowsServer eastus /Subscriptions/089d4ee9-0b8d-4bac-ab78-c12...
windowsserverdotnet MicrosoftWindowsServer eastus /Subscriptions/089d4ee9-0b8d-4bac-ab78-c12...
WindowsServerSemiAnnual MicrosoftWindowsServer eastus /Subscriptions/089d4ee9-0b8d-4bac-ab78-c12...
The Get-AzVMImageSku command will then filter on the publisher and offer name to return a list of image names.
Get-AzVMImageSku `
-Location "EastUS" `
-PublisherName "MicrosoftWindowsServer" `
-Offer "WindowsServer"
Skus Offer PublisherName Location Id
---- ----- ------------- -------- --
2008-R2-SP1 WindowsServer MicrosoftWindowsServer eastus /Subscriptions/089d4...
2008-R2-SP1-smalldisk WindowsServer MicrosoftWindowsServer eastus /Subscriptions/089d4...
2008-R2-SP1-zhcn WindowsServer MicrosoftWindowsServer eastus /Subscriptions/089d4...
2012-Datacenter WindowsServer MicrosoftWindowsServer eastus /Subscriptions/089d4...
Get-AzVMImageSku `
-Location "EastUS" `
-PublisherName "MicrosoftWindowsDesktop" `
-Offer "Windows-11"
Skus Offer PublisherName Location Id
---- ----- ------------- -------- --
win11-21h2-avd Windows-11 MicrosoftWindowsDesktop eastus /Subscriptions/089d4ee9-0b8d-4bac-ab78-c120f115e79e...
win11-21h2-ent Windows-11 MicrosoftWindowsDesktop eastus /Subscriptions/089d4ee9-0b8d-4bac-ab78-c120f115e79e...
win11-21h2-entn Windows-11 MicrosoftWindowsDesktop eastus /Subscriptions/089d4ee9-0b8d-4bac-ab78-c120f115e79e...
win11-21h2-pro Windows-11 MicrosoftWindowsDesktop eastus /Subscriptions/089d4ee9-0b8d-4bac-ab78-c120f115e79e...
win11-21h2-pro-zh-cn Windows-11 MicrosoftWindowsDesktop eastus /Subscriptions/089d4ee9-0b8d-4bac-ab78-c120f115e79e...
win11-21h2-pron Windows-11 MicrosoftWindowsDesktop eastus /Subscriptions/089d4ee9-0b8d-4bac-ab78-c120f115e79e...
Find the image of a exist VM in Azure
In the new Az PowerShell module you can check for source image as below:
$vm = (Get-AzVM -Name "VM Name")
$vm.StorageProfile.ImageReference
Publisher : microsoftwindowsdesktop
Offer : windows-11
Sku : win11-21h2-pro
Version : latest
ExactVersion : 22000.795.220629
SharedGalleryImageId :
CommunityGalleryImageId :
Id :
$vm = (Get-AzVM -Name poc-win10)
$vm.StorageProfile.ImageReference
Publisher : microsoftwindowsdesktop
Offer : Windows-10
Sku : 21h1-pro
Version : latest
ExactVersion : 19043.1826.220706
SharedGalleryImageId :
CommunityGalleryImageId :
Id :
$vm = (Get-AzVM -Name lab-server)
$vm.StorageProfile.ImageReference
Publisher : MicrosoftWindowsServer
Offer : WindowsServer
Sku : 2019-datacenter-gensecond
Version : latest
ExactVersion : 17763.3131.220505
SharedGalleryImageId :
CommunityGalleryImageId :
Id :
Now, you can create a new VM in Azure with Set-AzVMSourceImage:
Set-AzVMSourceImage `
-VM $VirtualMachine `
-PublisherName microsoftwindowsdesktop `
-Offer Windows-10 `
-Skus 21h1-pro `
-Version "latest"