foreach ($backup in $backups) {
foreach ($object in $objects) {
foreach ($storage in $storages) {
foreach ($job in $jobs) {
$table += Item
}
}
}
}
This means for every backup (There should be 4 most likely) you are iterating though every restore point in that backup (7). For every restore point you are iterating through every storage in the backup which will most likely be the same number as the number of restore points (7). And for Every Storage you are iterating through every job (4).
If we do the math from here with assumed numbers we get 7*7*4 = 196 objects added for each backup. Since there are most likely 4 backups you should end up with 196*4 = 784 total objects added to $Table. This is almost certainly not what you intend.
Your loops should be configured differently, you'd start with getting all jobs to report against, while you don't necessarily need to get all backups to start with. If you are going to get all jobs & backups, then I would still filter the jobs to also only select the matching JobType that you are looking for.
From that point, your jobs should be your outer loop, since that is really the core item you are trying to report against and is tied to everything else.
Then your next loop should be to get the backups associated with the job.
Your final inner loop would be where you get the storage files within each backup, then create your object to output to the pipeline.
A lot of this is personal preference, but if you construct it this way, each lookup only runs a query and returns the objects directly associated with your current object, therefore less overhead.