Hi Michael,
I am very sorry for being off the radar - been busy with various tasks lately.
Though we don't posses labs with jobs consisting of such amount of vms, I did test your script in 2 totally different labs to see the full picture. Both labs are with VBR v10:
- one with a total of 280 VMs backed up in almost 4k restore points. It all being a part of small jobs with approximately 2-30 VMs each.
- the other with backup copy job including 150 VMs (per-vm chains) with a total of almost 1.1k restore points.
So, I did see that your script runs differently for smaller vs. bigger jobs: 2 minutes in the first case (for all backups) vs. 11 minutes in the second case ( only for one backup!). And while it took some time in each iteration to get all objects in a backup, I didn't want to believe it takes that amount of time to get the information you are after.
What I finally found to be quite a consumer is a list of all restore points being parsed in each child loop iteration. Instead of just filtering already parsed restore points with needed vm names, powershell takes some time to run through them over and over invoking the cmdlet, extract those with fitting parameters and only then assign to a variable. When I put restore points invocation to the parent loop and just left the filtering in the child one be, it solved the case. Below you can see the whole script modified and stopwatch results for one iteration over backup with 150 VMs:
Code: Select all
$Veeam_VMs = @()
$backups = Get-VBRBackup -Name 'BackupCopy*';
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
for($i = 0; $i -lt $backups.Count; $i++) {
Write-Host "Backup" ($i + 1) "/" $backups.Count;
$vms = $backups[$i].GetObjects();
$restorePoints = Get-VBRRestorePoint -Backup $backups[$i]
for ($j = 0; $j -lt $vms.Count; $j++) {
$RPs = $restorePoints | Where {$_.VMName -eq $vms[$j].Name}
if ($RPs.Count -gt 1) {
$lastBackup = $RPs[$RPs.Count - 1].CreationTime;
} else {
$lastBackup = $RPs.CreationTime;
}
$object = New-Object System.Object
$object | Add-Member -Type NoteProperty -Name Uuid -Value $vms[$j].Uuid;
$object | Add-Member -Type NoteProperty -Name Name -Value $vms[$j].Name;
$object | Add-Member -Type NoteProperty -Name LastBackup -Value $lastBackup;
$Veeam_VMs += $object;
Write-Host " VM" ($j + 1) "/" $vms.Count "[Letzter 'RestorePoint' vom" $lastBackup "]";
}
}
$stopwatch.Elapsed
Days : 0
Hours : 0
Minutes : 0
Seconds : 38
Milliseconds : 272
Ticks : 382725691
TotalDays : 0.000442969549768519
TotalHours : 0.0106312691944444
TotalMinutes : 0.637876151666667
TotalSeconds : 38.2725691
TotalMilliseconds : 38272.5691
As per the stopwatch, one iteration took 11 minutes before I applied the changes.
Hope that helps!
Oleg