---
title: "Effortless Azure VM Snapshots with PowerShell"
description: "Create, manage, restore, and remove Azure VM snapshots using a community PowerShell module in just a few keystrokes!"
canonical: "https://adamtheautomator.com/azure-vm-snapshot/"
---

# Effortless Azure VM Snapshots with PowerShell

> Create, manage, restore, and remove Azure VM snapshots using a community PowerShell module in just a few keystrokes!

Source: https://adamtheautomator.com/azure-vm-snapshot/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Effortless Azure VM Snapshots with PowerShell](https://adamtheautomator.com/wp-content/uploads/2019/07/5d238ae5c824b514689ea64e.jpg)

# Effortless Azure VM Snapshots with PowerShell

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)1 July 20192 min. read

Categories: [Cloud](/category/cloud/)

Tags:[Azure Virtual Machines](/tag/azure-virtual-machines/)[Microsoft Azure](/tag/microsoft-azure/)[PowerShell](/tag/powershell/)

Table of Contents

*   [Before You Start](#before-you-start)
*   [Install the AzureVMSnapshots Module](#install-the-azurevmsnapshots-module)
*   [Creating an Azure VM Snapshot](#creating-an-azure-virtual-machine-snapshot)
*   [Finding Available Snapshots](#finding-available-snapshots)
*   [Restoring Snapshots](#restoring-snapshots)
*   [Removing Snapshots](#removing-snapshots)
*   [Summary](#summary)

If you’re used to right-clicking on a VM in your favorite hypervisor and creating a snapshot, you’ll be in for a rude awakening when running VMs in the Microsoft Azure cloud. But, don’t fret, with the know-how you’ll learn in this tutorial, you can build your own tooling to [create easy Azure VM snapshots](https://docs.microsoft.com/en-us/azure/virtual-machines/snapshot-copy-managed-disk?tabs=portal)!

Taking a snapshot or a backup of a VM is commonplace. There are always times when you need to back up a VM at a point in time and restore it at some later date. In the Azure cloud, it’s not quite as easy as clicking a few times though.

When a process isn’t as easy as you think it should be is a great time to build and use your own custom tool. You can rarely go wrong picking [PowerShell](https://adamtheautomator.com/tag/powershell/) as the scripting language of choice to make it happen.

In this article, you’re going to learn how to both back up and restore Azure virtual machines using a community PowerShell module called [AzureVMSnapshots](https://github.com/adbertram/AzureVmSnapshots).

## Before You Start

This article will be a tutorial showing you, step-by-step how to perform some tasks. If you’d like to follow along, please be sure you have met the following prerequisites:

1.  Windows PowerShell 5.1 or PowerShell 6+. The examples were only tested on PowerShell Core 6.2.3.
2.  An existing Azure VM – This VM will be used as the guinea pig to back up.
3.  The Azure PowerShell modules installed – `Install-Module Az` in your PowerShell console
4.  [Connected to an Azure subscription](https://adamtheautomator.com/connect-azaccount/)

## Install the AzureVMSnapshots Module

Installing the AzureVMSnapshots module is easy since it’s available via the PowerShell Gallery. Run `Install-Module AzureVMSnapshots` to get the module downloaded and installed.

## Creating an Azure VM Snapshot

Once you’ve got a PowerShell console opened and authenticated to the Azure subscription where your VM lives, create a new snapshot with `New-AzVmSnapshot`.

The `New-AzVmSnapshot` only requires two parameters – the name of the VM and the resource group its located in. You can see an example below of creating a snapshot for a VM called VM1 in the _Demo_ resource group.

Once executed, this may take a couple of minutes. In the background, Azure is stopping the VM and creating a snapshot. This cmdlet takes a snapshot of the OS disk.

```powershell
New-AzVmSnapshot -VmName VM1 -ResourceGroupName 'Demo'
```

> _If you don’t want to shut down the VM, do NOT run this command!_

## Finding Available Snapshots

When you create a snapshot, they will be saved with a specific schema in the name. Regardless if you’ve created other snapshots another way, the AzureVMASnapshot module’s `Get-AzVmSnapshot` command will only return snapshots created with the module.

Below you can see an example of retrieving all snapshots stored in the _Demo_ resource group.

```powershell
Get-AzVmSnapshot -ResourceGroupName 'Demo'
```

## Restoring Snapshots

Perhaps you’ve made some changes to the VM you didn’t meant to and would like to restore a snapshot. To restore snapshots, you can pipe a snapshot returned via `Get-AzVmSnapshot` to the `Restore-AzVmSnapshot` command like the example below.

```powershell
Get-AzVmSnapshot -ResourceGroupName 'Demo' -VmName VM1 | Restore-AzVmSnapshot
```

When this command runs, you will then get prompted if you’d really like to restore the VM. If so, the VM will be shut down and the original source disk replaced with the snapshot disk.

> _Note: By default, `Restore-AzVmSnapshot` will leave the old disk. If you’d like to remove it after restoration is complete, use the `RemoveOriginalDisk`  parameter._

## Removing Snapshots

Finally, if you don’t need a snapshot or set of snapshots anymore, you can remove them with the `Remove-AzVmSnapshot` command. The concept to remove a snapshot is the same as restoring one – pipe the snapshot from `Get-AzVmSnapshot` to `Remove-AzVmSnapshot`.

```powershell
Get-AzVmSnapshot -ResourceGroupName 'Demo' -VmName VM1 | Remove-AzVmSnapshot
```

## Summary

Using a community [PowerShell module](https://adamtheautomator.com/powershell-modules/) and just a few commands, you can easily create, manage, restore and remove Azure VM snapshots with just a few keystrokes!

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fazure-vm-snapshot%2F&text=Effortless%20Azure%20VM%20Snapshots%20with%20PowerShell)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fazure-vm-snapshot%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fazure-vm-snapshot%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2019/12/network-2402637_1280.jpg)

### [Optimize Azure Scale Sets Management with PowerShell](/azure-powershell-scale-set/)

Master Azure Scale Sets management using PowerShell. Learn to create, configure, and automate VM scale sets for improved cloud infrastructure.

![](https://adamtheautomator.com/wp-content/uploads/2019/07/iot-3337536_1280.png)

### [Run Scripts on Azure VMs with Custom Script Extension](/azure-run-script-on-vm/)

Remotely run PowerShell scripts on your Azure VMs using the Azure custom script extension for Windows.

![](https://adamtheautomator.com/wp-content/uploads/2019/07/5d238ae5c824b514689ea66d.jpg)

### [Delete Azure VMs & Clean Up with PowerShell](/azure-vm-delete/)

Learn how to delete an Azure VM and clean up related resources using the Remove-AzVM PowerShell command.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
