Code: Select all
Add-PSSnapin VeeamPSSnapin
$Jobs = Get-VBRJob -name "DC_Test"
#$Jobs = Get-VBRBackup -name "DC_Test"
foreach ($Job in $Jobs) {
Write-Host "Job: " -NonewLine
echo $Job.name
#Skip if Job is Disabled
if (! $job.info.IsScheduleEnabled) {
echo "Skipping disabled job..."
echo ""
continue
}
$vms = $job.GetObjectsInJob()
foreach ($vm in $vms) {
Write-Host "VM: " -NonewLine
echo $vm.Name
$rp = Get-VBRRestorePoint -Name $vm.name | Sort-Object -Property CreationTime -Descending | Select -First 1
Write-Host "RP Creation Time: " -NoNewLine
echo $rp.CreationTime
echo "Exporting backup to file..."
#echo $rp
Export-VBRBackup -RestorePoint $rp -Dir "C:\Export"
}
echo ""
}
Code: Select all
Export-VBRBackup : The file 'C:\Export\DC_TestD2019-04-10T160035_84FF.vib' already exists.
At C:\Veeam export script\Exportv2.ps1:25 char:5
+ Export-VBRBackup -RestorePoint $rp -Dir "C:\Export"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Export-VBRBackup], IOException
+ FullyQualifiedErrorId : System.IO.IOException,Veeam.Backup.PowerShell.Cmdlets.ExportVBRBackup
Or am I going about this all wrong?