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

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.

Links

Zero to Hero with Azure Virtual Desktop https://www.udemy.com/course/zero-to-hero-with-windows-virtual-desktop/?referralCode=B2FE49E6FCEE7A7EA8D4

Image Builder Playlist
https://youtube.com/playlist?list=PLnWpsLZNgHzWeiHA_wG0xuaZMlk1Nag7E

GitHub Repo https://github.com/tsrob50/WVD-Public
SnapImage.ps1 https://github.com/tsrob50/WVD-Public/blob/master/SnapImage.ps1
SysprepCSE.ps1 https://raw.githubusercontent.com/tsrob50/WVD-Public/master/SysprepCSE.ps1

Sysprep fails after remove Microsoft Store Apps
https://docs.microsoft.com/en-us/troubleshoot/windows-client/deployment/sysprep-fails-remove-or-update-store-apps

Leave a Comment

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

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

Scroll to Top