Veeam Scheduled Restore Powershell Script for Hyper-V

As part of Business Continuity and Disaster Recovery, testing integrity of backups is mandatory. Within a datacenter, there may be thousands of backups to test. Here are some quick and dirty guidelines to use when performing scheduled restores using Veeam and Robocopy.

Create a VHDX onto which to recover data
Mount the VHDX as a Drive Letter, e.g. R:

#Use Veeam Powershell Snapin
Add-PSSnapin VeeamPSSnapin

#Veeam Restore script
$result = Get-VBRBackup | where {$_.jobname -eq "<JOBNAME>"} | Get-VBRRestorePoint | where {$_.name -eq "<VMNAME>"} | Sort-Object creationtime -Descending | Select-Object -First 1 | Start-VBRWindowsFileRestore
If($result -eq $null)
{
   Write-Output "Info: $(Get-Date) - No backup found for <VMNAME>"
   exit
}


$Files1 = "<SOURCEPATH>"
$RestoreDestination1 = "R:\<DESTINATION>"
$File1 = $Result.Drives.Substring($Result.Drives.LastIndexOf(" ")).substring(1) + (split-path -NoQualifier "$Files1")
robocopy "$File1" "$RestoreDestination1" /MIR /R:0 /NFL /NDL