In this Microsoft Azure PowerShell post, We’ll walk through how to restore the OS disk of an Azure VM using PowerShell.

Restoring a virtual machine (VM) OS disk in Azure is a critical task when recovering from corruption, accidental deletion, or software failure.

Prerequisites

Ensure you have the following before proceeding:

  • Azure PowerShell module installed and updated
  • Appropriate permissions to access Recovery Services Vault and VM backups
  • A Recovery Services Vault with at least one recovery point for your VM

Step-by-Step: Restoring the OS Disk

We’ll walk through the process using a sample environment. Update the resource names to match your actual environment.

1. Set the Recovery Services Vault Context

2. Get the Backup Container and Item

3. Get the Recovery Point

Specify the time range from which you’d like to retrieve the recovery point.

You can inspect the $rp variable to choose the most suitable recovery point. For example:

4. Restore the OS Disk

Choose the desired recovery point and initiate the restore. This will restore only the OS disk to the specified storage account and resource group.

Note: This command does not overwrite the existing VM. It creates a new managed disk from the OS disk recovery point, which you can later attach to a new or existing VM.

After the Restore

Once the OS disk is restored, you can:

  • Create a new VM using the restored disk
  • Replace the disk on the original VM (requires VM to be deallocated)
  • Mount it as a data disk to extract files

In the next article we will show how to replace an existing OS disk with a restored.

Conclusion

Using Azure PowerShell, restoring an Azure VM OS disk is straightforward and gives you control over the recovery process. Always ensure you select the correct recovery point and validate the disk post-restore before putting it into production.


Discover more from CPI Consulting Pty Ltd Experts in Cloud, AI and Cybersecurity

Subscribe to get the latest posts sent to your email.

Discover more from CPI Consulting Pty Ltd Experts in Cloud, AI and Cybersecurity

Subscribe now to keep reading and get access to the full archive.

Continue reading