Use PowerShell to Create a Snapshot Based Image of an Azure Virtual Machine

PowerShell Image Snapshot

This video goes of using the SnapImage.ps1 PowerShell script.  This script automates the process of creating an image from an Azure VM without destroying it during the capture process.  At a high-level, the following steps are taken:

Snapshot of source “reference” VM > create a temp “capture” Resource Group > OS disk from snapshot > create a VNet and VM in the capture RG > sysprep the VM with a Custom Script Extension > capture the VM > If using Azure Compute Gallery, add image to the gallery, If not using Azure Compute Gallery, add image to reference VM Resource Group > remove capture Resource Group > remove snapshot

Please read the description and notes in the script before running.  If the script hangs on the sysprep step, verify the reference computer is ready for sysprep including all updates are applied or automatic updates are disabled, and there are no per-user Microsoft store applications installed.


Zero to Hero with Azure Virtual Desktop

Image Builder Playlist

GitHub Repo

Sysprep fails after remove Microsoft Store Apps

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.