
Remove-AzureRMVM -ResourceGroupName $resourceGroupName -Name $vmName -Force $ManagedDataDisk = Get-AzureRMDisk -ResourceGroupName $resourceGroupName -DiskName $ManagedDataDiskName $ManagedDisk = Get-AzureRMDisk -ResourceGroupName $resourceGroupName -DiskName $ManagedDiskName $diagContainer = Get-AzureStorageContainer | Where-Object Set-AzureRmCurrentStorageAccount –ResourceGroupName $resourceGroupName –StorageAccountName $diagStorageAcc #Get Boot Diagnostic storage container to be deleted $VmId = $vm.VmId #Gets and sets VMId - Used to remove the diagnostics storage account. #Get existing NIC to use during re-create Stop-AzureRmVM -ResourceGroupName $resourceGroupName -Name $vmName -Force $vm = Get-AzureRMVM -ResourceGroupName $resourceGroupName -Name $vmName $DataSnapshotName = "DataDiskSnapshotName" #Update Data Disk SnapshotName $snapshotName = "OSDiskSnapshotNAme" #Update OS Disk SnapshotName $diagStorageAcc = "DiagStorageAcct" #Update if required $resourceGroupName = "ResourceGroupName" #Update if required $location = "Location" #Update if required I'm sure this could be refined more but it does what we need it to. Its also tailored to allow for one data disk as an automatic restore. We do it slightly differently to the Microsoft docs by retaining the original components, nic / pip etc. I've had a lot of requests for this script so hopefully it helps. The scripts are available in my GitHub repo here: Creating a snapshot #Ĭreate-DiskSnapshot.ps1 creates an Azure Disk Snapshot in the same location as the source disk.First off - sorry for the late response. Going through this process a few times led me to creating some PowerShell scripts to automate this process (and create this blog post!).Īfter understanding the steps needed and the PowerShell cmdlets for each, the next step was of course to write scripts to automate all the individual steps. This allowed me to practice my demo over and over and over again, make adjustments, and then practice some more.

Two: I could take a snapshot of the VM, run through my demo, and then revert the VM to it’s pre-demo state. Using a fresh machine ensured I had to account for everything. I didn’t want to demo from my machine and forget about some random configuration or setting. One: I was preparing the demo from a base Windows 10 machine (or pretty close to it), so I was pretty confident that my material would work for anyone else.


I used a virtual machine in Azure to perform the demo which gave me two great benefits. This gave me the chance to practice, and rehearse, and fine tune my content. I recently prepared a Lightning Demo for the 2021 PowerShell + DevOps Global Summit, which thankfully was a pre-recorded session and not live.
