Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • VirtualBox
  • VMware
  • Windows
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • VirtualBox
  • VMware
  • Windows
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Find the VM Image Used to Create an Azure VM using PowerShell

September 2, 2022
in Blog, Microsoft Azure, Powershell
0
ADVERTISEMENT

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...
ADVERTISEMENT

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"
ADVERTISEMENT
5/5 - (1 vote)
Previous Post

How to Enable and Connect to Microsoft Azure Cloud Shell

Next Post

How to Find Azure Marketplace VM Images with Azure PowerShell

Related Posts

Ftr38

[WinForms] Creating GUIs in Windows PowerShell with WinForms

November 15, 2023
Ftr21

Converting DateTime Obtained from Microsoft Graph Call to PowerShell Date and Time Format

October 21, 2023
Ftr21

Translate Microsoft 365 License GUIDs to Product Names in PowerShell Microsoft Graph

October 19, 2023
Ftr21

How to Get an Access Token for Microsoft Graph PowerShell / API

November 27, 2023
Ftr21

Getting Access Token for Microsoft Graph

November 27, 2023
Ftr5

How to Copy Files without Changing Date Creation Time on Windows

November 27, 2023

Leave a Reply Cancel reply

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

Recent Posts

  • [WinForms] Creating GUIs in Windows PowerShell with WinForms
  • Converting DateTime Obtained from Microsoft Graph Call to PowerShell Date and Time Format
  • Translate Microsoft 365 License GUIDs to Product Names in PowerShell Microsoft Graph

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2023 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory