<div dir="ltr" style="text-align: left;">The following graphic shows the object hierarchy from the RecoveryServicesVault down to the BackupRecoveryPoint.</p>
<div style="clear: both; text-align: center;"><a href="http://www.thecloudxperts.co.uk/wp-content/uploads/2017/10/download.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="165" data-original-width="306" src="http://www.thecloudxperts.co.uk/wp-content/uploads/2017/10/download.png" /></a></div>
<div>To restore backup data, identify the backed-up item and the recovery point that holds the point-in-time data. Use the <strong><span style="background: yellow; font-family: ";calibri"; , ";sans-serif";;">Restore-AzureRmRecoveryServicesBackupItem</span></strong>cmdlet to restore data from the vault to the customer&#8217;s account.<o:p></o:p></div>
<p>The following graphic shows the object hierarchy from the RecoveryServicesVault down to the BackupRecoveryPoint.<o:p></o:p></p>
<div style="clear: both; text-align: center;"><a href="http://www.thecloudxperts.co.uk/wp-content/uploads/2017/10/backuprecoverypoint-only.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="112" data-original-width="804" height="88" src="http://www.thecloudxperts.co.uk/wp-content/uploads/2017/10/backuprecoverypoint-only-300x42.png" width="640" /></a></div>
<p></p>
<div><!--[if gte vml 1]><v:shapetype coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"/> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"/> <v:f eqn="sum @0 1 0"/> <v:f eqn="sum 0 0 @1"/> <v:f eqn="prod @2 1 2"/> <v:f eqn="prod @3 21600 pixelWidth"/> <v:f eqn="prod @3 21600 pixelHeight"/> <v:f eqn="sum @0 0 1"/> <v:f eqn="prod @6 1 2"/> <v:f eqn="prod @7 21600 pixelWidth"/> <v:f eqn="sum @8 21600 0"/> <v:f eqn="prod @7 21600 pixelHeight"/> <v:f eqn="sum @10 21600 0"/> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/> <o:lock v:ext="edit" aspectratio="t"/></v:shapetype><v:shape id="Picture_x0020_1" o:sp type="#_x0000_t75" style='width:451.5pt;height:63pt;visibility:visible;mso-wrap-style:square'> <v:imagedata src="file:///C:Usersbabar.ziaAppDataLocalTempmsohtmlclip1 1clip_image001.png" o:title=""/></v:shape><![endif]--><!--[if !vml]--><!--[endif]--><o:p></o:p></div>
<div style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; mso-outline-level: 3;"><b><span style="font-family: ";times new roman"; , ";serif";; font-size: 13.5pt;">Select the VM<o:p></o:p></span></b></div>
<div style="line-height: normal; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"><span style="font-family: ";times new roman"; , ";serif";; font-size: 12.0pt;">To get the PowerShell object that identifies the right backup item, start from the container in the vault, and work your way down the object hierarchy. To select the container that represents the VM,<o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$VaultName</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> <span style="color: darkred;">&#8220;Vaultname&#8221;</span><span style="color: darkgreen;"># Vault Name for Recovery Points (Backups)</span><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$VmName</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> <span style="color: darkred;">&#8220;vmname&#8221;</span> <span style="color: darkgreen;"># VM Name of the backup to be used<o:p></o:p></span></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$StAcName</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> <span style="color: darkred;">&#8220;storageaccountname&#8221;</span> <span style="color: darkgreen;"># ; Storage Account Name to be used for recovery<o:p></o:p></span></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: ";lucida console";; font-size: 9.0pt;">$StAcRGName = &#8220;storageaccountRG<span style="color: #00b050;">&#8221; #Storage Account Resource Group Name<o:p></o:p></span></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$VaultName</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> <span style="color: darkred;">&#8220;xxxx&#8221;</span><span style="color: darkgreen;"># Vault Name for Recovery Points (Backups)</span><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$VmName</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> <span style="color: darkred;">&#8220;xxxxxx&#8221;</span> <span style="color: darkgreen;"># VM Name of the backup to be used</span><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$StAcName</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> <span style="color: darkred;">&#8220;xxxxx&#8221;</span> <span style="color: darkgreen;"># ; Storage Account Name to be used for recovery</span><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$StAcRGName</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> <span style="color: darkred;">&#8220;xxxx&#8221;</span><span style="color: darkgreen;"># Storage Account Resource Group Name</span><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$Region</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> <span style="color: darkred;">&#8220;UK South&#8221;</span><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$RestoredVmName</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> <span style="color: darkred;">&#8220;xxxxx&#8221;</span><span style="color: darkgreen;"># Name for Restored VM (Can be same name as source if souce has been deleted)</span><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$destination_path</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> <span style="color: darkred;">&#8220;C:tempvmconfig.json&#8221;</span><span style="color: darkgreen;"># Path to download config file</span><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: darkgreen; font-family: ";lucida console";; font-size: 9.0pt;">#Select Vault</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: ";lucida console";; font-size: 9.0pt;">Get-AzureRmRecoveryServicesVault</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: navy;">-Name</span> <span style="color: orangered;">$VaultName</span><span style="color: darkgrey;">|</span> <span style="color: blue;">Set-AzureRmRecoveryServicesVaultContext</span><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: darkgreen; font-family: ";lucida console";; font-size: 9.0pt;">#Select VM</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$backupitem</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> <span style="color: blue;">Get-AzureRmRecoveryServicesBackupItem</span><span style="color: navy;">-BackupManagementType</span> <span style="color: blueviolet;">AzureVM</span><span style="color: navy;">-WorkloadType</span> <span style="color: blueviolet;">AzureVM</span><span style="color: navy;">-Name</span> <span style="color: orangered;">$VmName</span><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"></div>
<h3>Choose a Recovery point<o:p></o:p></h3>
<p>Use the <strong><span style="background: yellow; mso-fareast-font-family: ";Times New Roman";; mso-fareast-theme-font: major-fareast; mso-highlight: yellow;">Get-AzureRmRecoveryServicesBackupRecoveryPoint</span></strong>cmdlet to list all recovery points for the backup item. Then choose the recovery point to restore. If you are unsure which recovery point to use, it is a good practice to choose the most recent RecoveryPointType = AppConsistent point in the list.<o:p></o:p><br />In the following script, the variable, <strong>$rp</strong>, is an array of recovery points for the selected backup item, from the past seven days. The array is sorted in reverse order of time with the latest recovery point at index 0.<o:p></o:p></p>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: darkgreen; font-family: ";lucida console";; font-size: 9.0pt;">#### List available recovery points for up to 7 days old or alter value (-7)</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$startDate</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> (<span style="color: blue;">Get-Date</span>)<span style="color: darkgrey;">.</span>AddDays(<span style="color: purple;">-7</span>)<o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$endDate</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> <span style="color: blue;">Get-Date</span><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: darkgreen; font-family: ";lucida console";; font-size: 9.0pt;">#Select Recovery point</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$rp</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> <span style="color: blue;">Get-AzureRmRecoveryServicesBackupRecoveryPoint</span> <span style="color: navy;">-Item</span> <span style="color: orangered;">$backupitem</span><span style="color: navy;">-StartDate</span> <span style="color: orangered;">$startdate</span><span style="color: darkgrey;">.</span>ToUniversalTime() <span style="color: navy;">-EndDate</span><span style="color: orangered;">$enddate</span><span style="color: darkgrey;">.</span>ToUniversalTime()<o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$rp</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">|</span> <span style="color: blue;">ft</span><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: darkgreen; font-family: ";lucida console";; font-size: 9.0pt;">#Select the restore point &#8211; 0 = Most recent RP, 1 = 2nd newest RP etc&#8230;</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: ";lucida console";; font-size: 9.0pt;">Write-Host</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkred;">&#8220;Select the restore point &#8211; latest is 0, next is 1 etc&#8230;&#8221;</span> <span style="color: navy;">-ForegroundColor</span> <span style="color: blueviolet;">Red</span><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$rpselected</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> (<span style="color: orangered;">$input</span> <span style="color: darkgrey;">=</span> <span style="color: blue;">Read-Host</span>)<o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$rps</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> <span style="color: orangered;">$rp</span><span style="color: darkgrey;">[</span><span style="color: orangered;">$rpselected</span><span style="color: darkgrey;">]</span><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: darkgreen; font-family: ";lucida console";; font-size: 9.0pt;">#### Define Storage Account to be used</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"><span style="color: orangered; font-family: ";lucida console";; font-size: 9.0pt;">$restorejob</span><span style="font-family: ";lucida console";; font-size: 9.0pt;"> <span style="color: darkgrey;">=</span> <span style="color: blue;">Restore-AzureRMRecoveryServicesBackupItem</span><span style="color: navy;">-RecoveryPoint</span> <span style="color: orangered;">$rps</span><span style="color: navy;">-StorageAccountName</span> <span style="color: orangered;">$StAcName</span><span style="color: navy;">-StorageAccountResourceGroupName</span> <span style="color: orangered;">$StAcRGName</span><o:p></o:p></span></div>
<div style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; mso-layout-grid-align: none; text-autospace: none;"></div>
<div><span style="font-family: ";lucida console";; font-size: 9.0pt; line-height: 115%;">#### Start Restore Job<o:p></o:p></span></div>
<div><span style="font-family: ";lucida console";; font-size: 9.0pt; line-height: 115%;">$restorejob<o:p></o:p></span></div>
<div></div>
<div><span style="background: yellow; font-family: ";lucida console";; font-size: 9.0pt; line-height: 115%;">#### Monitor job status</span><span style="font-family: ";lucida console";; font-size: 9.0pt; line-height: 115%;"><o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: ";lucida console";; font-size: 9.0pt; line-height: 115%;">Do {<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: ";lucida console";; font-size: 9.0pt; line-height: 115%;">Start-Sleep -Seconds 180<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: ";lucida console";; font-size: 9.0pt; line-height: 115%;">Get-Date -Format T<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: ";lucida console";; font-size: 9.0pt; line-height: 115%;">$JobStatus = Get-AzureRmRecoveryServicesBackupJobDetails -job $restorejob<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: ";lucida console";; font-size: 9.0pt; line-height: 115%;">$JobStatus<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: ";lucida console";; font-size: 9.0pt; line-height: 115%;">$JobStatusCheck = $JobStatus.Status<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: ";lucida console";; font-size: 9.0pt; line-height: 115%;">} While ($JobStatusCheck -eq &#8220;InProgress&#8221;)<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: ";lucida console";; font-size: 9.0pt; line-height: 115%;">If ($JobStatusCheck -ne &#8220;Completed&#8221;) {<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: ";lucida console";; font-size: 9.0pt; line-height: 115%;">Write-Host &#8220;Seems Job has not completed successfully!&#8221;<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: ";lucida console";; font-size: 9.0pt; line-height: 115%;">exit<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"><span style="font-family: ";lucida console";; font-size: 9.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"></div>
<p><span style="background: yellow; mso-highlight: yellow;">Once the Restore job has completed, use the </span><strong><span style="background: yellow; mso-fareast-font-family: ";Times New Roman";; mso-fareast-theme-font: major-fareast; mso-highlight: yellow;">Get-AzureRmRecoveryServicesBackupJobDetails</span></strong><span style="background: yellow; mso-highlight: yellow;"> cmdlet to get the details of the restore operation. The JobDetails property has the information needed to rebuild the VM.</span><o:p></o:p></p>
<pre><code>PS C:>; $restorejob = Get-AzureRmRecoveryServicesBackupJob -Job $restorejob<o:p></o:p></code></pre>
<pre><code>PS C:>; $details = Get-AzureRmRecoveryServicesBackupJobDetails -Job $restorejob<o:p></o:p></code></pre>
<p><span style="font-family: ";lucida console";; font-size: 9.0pt; line-height: 115%;"><br clear="all" style="mso-special-character: line-break; page-break-before: always;" /></span> </p>
<div style="margin-bottom: .0001pt; margin-bottom: 0cm;"></div>
<h2>Create a VM from restored disks<o:p></o:p></h2>
<p>After you have restored the disks, use these steps to create and configure the virtual machine from disk.<o:p></o:p></p>
<div>[!NOTE] To create encrypted VMs from restored disks, your Azure role must have permission to perform the action, <strong><span style="font-family: ";calibri"; , ";sans-serif";; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: ";Times New Roman";; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;">Microsoft.KeyVault/vaults/deploy/action</span></strong>. If your role does not have this permission, create a custom role with this action.<o:p></o:p></div>
<div></div>
<div style="line-height: normal; margin-left: 18.0pt; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 18.0pt; text-indent: -18.0pt;"><!--[if !supportLists]--><span style="font-family: ";times new roman"; , ";serif";; font-size: 12.0pt;">1.<span style="font-family: ";times new roman";; font-size: 7pt; font-stretch: normal; line-height: normal;"> ; ; ; ; ; </span></span><!--[endif]--><span style="font-family: ";times new roman"; , ";serif";; font-size: 12.0pt;">Query the restored disk properties for the job details.<o:p></o:p></span></div>
<div style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 18.0pt; margin-right: 0cm; margin-top: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: ";courier new";; font-size: 10.0pt;">PS C:>; $properties = $details.properties<o:p></o:p></span></div>
<div style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 18.0pt; margin-right: 0cm; margin-top: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: ";courier new";; font-size: 10.0pt;">PS C:>; $storageAccountName = $properties[&#8220;Target Storage Account Name&#8221;]<o:p></o:p></span></div>
<div style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 18.0pt; margin-right: 0cm; margin-top: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: ";courier new";; font-size: 10.0pt;">PS C:>; $containerName = $properties[&#8220;Config Blob Container Name&#8221;]<o:p></o:p></span></div>
<div style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 18.0pt; margin-right: 0cm; margin-top: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: ";courier new";; font-size: 10.0pt;">PS C:>; $blobName = $properties[&#8220;Config Blob Name&#8221;]<o:p></o:p></span></div>
<div style="line-height: normal; margin-left: 18.0pt; mso-list: l1 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 18.0pt; text-indent: -18.0pt;"><!--[if !supportLists]--><span style="font-family: ";times new roman"; , ";serif";; font-size: 12.0pt;">2.<span style="font-family: ";times new roman";; font-size: 7pt; font-stretch: normal; line-height: normal;"> ; ; ; ; ; </span></span><!--[endif]--><span style="font-family: ";times new roman"; , ";serif";; font-size: 12.0pt;">Set the Azure storage context and restore the JSON configuration file.<o:p></o:p></span></div>
<div style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 18.0pt; margin-right: 0cm; margin-top: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: ";courier new";; font-size: 10.0pt;">PS C:>; Set-AzureRmCurrentStorageAccount -Name $storageaccountname -ResourceGroupName &#8220;testvault&#8221;<o:p></o:p></span></div>
<div style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 18.0pt; margin-right: 0cm; margin-top: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: ";courier new";; font-size: 10.0pt;">PS C:>; $destination_path = &#8220;C:vmconfig.json&#8221;<o:p></o:p></span></div>
<div style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 18.0pt; margin-right: 0cm; margin-top: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: ";courier new";; font-size: 10.0pt;">PS C:>; Get-AzureStorageBlobContent -Container $containerName -Blob $blobName -Destination $destination_path<o:p></o:p></span></div>
<div style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; margin-left: 18.0pt; margin-right: 0cm; margin-top: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: ";courier new";; font-size: 10.0pt;">PS C:>; $obj = ((Get-Content -Path $destination_path -Raw -Encoding Unicode)).TrimEnd([char]0x00) | ConvertFrom-Json<o:p></o:p></span></div>
<div style="line-height: normal; margin-left: 18.0pt; mso-add-space: auto; mso-list: l1 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 18.0pt; text-indent: -18.0pt;"><!--[if !supportLists]--><span style="font-family: ";times new roman"; , ";serif";; font-size: 12.0pt;">3.<span style="font-family: ";times new roman";; font-size: 7pt; font-stretch: normal; line-height: normal;"> ; ; ; ; ; </span></span><!--[endif]--><span style="font-family: ";times new roman"; , ";serif";; font-size: 12.0pt;">Use the JSON configuration file to create the VM configuration.<o:p></o:p></span></div>
<div style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: ";courier new";; font-size: 10.0pt;">PS C:>; $vm = New-AzureRmVMConfig -VMSize $obj.&#8217;properties.hardwareProfile&#8217;.vmSize -VMName &#8220;testrestore&#8221;<o:p></o:p></span></div>
<div style="line-height: normal; margin-left: 18.0pt; mso-add-space: auto; mso-list: l1 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 18.0pt; text-indent: -18.0pt;"><!--[if !supportLists]--><span style="font-family: ";times new roman"; , ";serif";; font-size: 12.0pt;">4.<span style="font-family: ";times new roman";; font-size: 7pt; font-stretch: normal; line-height: normal;"> ; ; ; ; ; </span></span><!--[endif]--><span style="font-family: ";times new roman"; , ";serif";; font-size: 12.0pt;">Attach the OS disk and data disks. Depending on the configuration of your VMs, refer to the relevant section to view respective cmdlets:<o:p></o:p></span></div>
<div style="line-height: normal; margin-left: 18.0pt; mso-add-space: auto; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;"></div>
<h4 style="margin-left: 36.0pt;">Non-managed, non-encrypted VMs<o:p></o:p></h4>
<div style="margin-left: 36.0pt;">Use the following sample for non-managed, non-encrypted VMs.<o:p></o:p></div>
<pre style="margin-left: 36.0pt;"><code>PS C:>; Set-AzureRmVMOSDisk -VM $vm -Name "osdisk" -VhdUri $obj.'properties.StorageProfile'.osDisk.vhd.Uri -CreateOption "Attach"<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code>PS C:>; $vm.StorageProfile.OsDisk.OsType = $obj.'properties.StorageProfile'.OsDisk.OsType<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code>PS C:>; foreach($dd in $obj.'properties.StorageProfile'.DataDisks)<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code>{<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code>$vm = Add-AzureRmVMDataDisk -VM $vm -Name "datadisk1" -VhdUri $dd.vhd.Uri -DiskSizeInGB 127 -Lun $dd.Lun -CreateOption "Attach"<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code>}<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code> ;</code></pre>
<h4 style="margin-left: 36.0pt;">Managed, non-encrypted VMs<o:p></o:p></h4>
<div style="margin-left: 36.0pt;">For managed non-encrypted VMs, you&#8217;ll need to create managed disks from blob storage, and then attach the disks. For in-depth information, see the article, Attach a data disk to a Windows VM using PowerShell. The following sample code shows how to attach the data disks for managed non-encrypted VMs.<o:p></o:p></div>
<pre style="margin-left: 36.0pt;"><code>PS C:>; $storageType = "StandardLRS"<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code>PS C:>; $osDiskName = $vm.Name + "_osdisk"<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code>PS C:>; $osVhdUri = $obj.'properties.storageProfile'.osDisk.vhd.uri<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code>PS C:>; $diskConfig = New-AzureRmDiskConfig -AccountType $storageType -Location "West US" -CreateOption Import -SourceUri $osVhdUri<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code>PS C:>; $osDisk = New-AzureRmDisk -DiskName $osDiskName -Disk $diskConfig -ResourceGroupName "test"<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code>PS C:>; Set-AzureRmVMOSDisk -VM $vm -ManagedDiskId $osDisk.Id -CreateOption "Attach" -Windows<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code>PS C:>; foreach($dd in $obj.'properties.storageProfile'.dataDisks)<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code> {<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code> $dataDiskName = $vm.Name + $dd.name ;<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code> $dataVhdUri = $dd.vhd.uri ;<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code> $dataDiskConfig = New-AzureRmDiskConfig -AccountType $storageType -Location "West US" -CreateOption Import -SourceUri $dataVhdUri ;<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code> $dataDisk2 = New-AzureRmDisk -DiskName $dataDiskName -Disk $dataDiskConfig -ResourceGroupName "test" ;<o:p></o:p></code></pre>
<pre style="margin-left: 36.0pt;"><code> Add-AzureRmVMDataDisk -VM $vm -Name $dataDiskName -ManagedDiskId $dataDisk2.Id -Lun $dd.Lun -CreateOption "Attach"<o:p></o:p></code></pre>
<pre style="margin-left: 45.8pt;"><code>}<o:p></o:p></code></pre>
<pre style="margin-left: 45.8pt;"><code> ;</code></pre>
<pre style="margin-left: 18.0pt; mso-list: l1 level1 lfo2; tab-stops: list 18.0pt left 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-indent: -18.0pt;"><!--[if !supportLists]--><b><span style="font-family: ";times new roman"; , ";serif";; font-size: 12.0pt;">5.<span style="font-family: ";times new roman";; font-size: 7pt; font-stretch: normal; font-weight: normal; line-height: normal;"> ; ; ; ; ; </span></span></b><!--[endif]--><b><span style="font-family: ";times new roman"; , ";serif";; font-size: 12.0pt;">Set the Network settings.<o:p></o:p></span></b></pre>
<pre><o:p> ;</o:p></pre>
<div style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: ";courier new";; font-size: 10.0pt;">PS C:>; $nicName=&#8221;p1234&#8243;<o:p></o:p></span></div>
<div style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: ";courier new";; font-size: 10.0pt;">PS C:>; $pip = New-AzureRmPublicIpAddress -Name $nicName -ResourceGroupName &#8220;test&#8221; -Location &#8220;WestUS&#8221; -AllocationMethod Dynamic<o:p></o:p></span></div>
<div style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: ";courier new";; font-size: 10.0pt;">PS C:>; $vnet = Get-AzureRmVirtualNetwork -Name &#8220;testvNET&#8221; -ResourceGroupName &#8220;test&#8221;<o:p></o:p></span></div>
<div style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: ";courier new";; font-size: 10.0pt;">PS C:>; $nic = New-AzureRmNetworkInterface -Name $nicName -ResourceGroupName &#8220;test&#8221; -Location &#8220;WestUS&#8221; -SubnetId $vnet.Subnets[$subnetindex].Id -PublicIpAddressId $pip.Id<o:p></o:p></span></div>
<div style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: ";courier new";; font-size: 10.0pt;">PS C:>; $vm=Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id<o:p></o:p></span></div>
<pre><code> ;</code></pre>
<div style="line-height: normal; margin-left: 18.0pt; mso-add-space: auto; mso-list: l1 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list 18.0pt; text-indent: -18.0pt;"><!--[if !supportLists]--><b><span style="font-family: ";times new roman"; , ";serif";; font-size: 12.0pt;">6.<span style="font-family: ";times new roman";; font-size: 7pt; font-stretch: normal; font-weight: normal; line-height: normal;"> ; ; ; ; ; </span></span></b><!--[endif]--><b><span style="font-family: ";times new roman"; , ";serif";; font-size: 12.0pt;">Create the virtual machine.<o:p></o:p></span></b></div>
<div style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0cm; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;"><span style="font-family: ";courier new";; font-size: 10.0pt;">PS C:>; New-AzureRmVM -ResourceGroupName &#8220;test&#8221; -Location &#8220;WestUS&#8221; -VM $vm<o:p></o:p></span></div>
<p></p>
<div></div>
</div>

