Hey
@matteu,
This is a more complex question than it seems
In "most" cases, you can get away with passing the CBackupJob object returned from Get-VBRJob to Get-VBRJobObject
This will give you output like:
Code: Select all
PS C:\Users\Administrator> $job |Get-VBRJobObject
Name Type ApproxSize Location
---- ---- ---------- --------
DDom-TinyVM_migrated Include 0 B somevcenter...
somevcenter.lo... Include 9.6 TB somevcenter...
And you can sum up ApproxSize value.
Note that you need to consider if you want to count the excluded objects also (they will have Type -eq Exclude), but that's a decision best left for you
Backup Copies are unique though in that you can also add objects by LinkedJob property, so you need to do some logic to check if there are linked jobs (Linked Backups work alright and add infrastructure objects so no need for special handling):
Code: Select all
$job = Get-VBRjob -name 'somebackupcopy'
if($job.LinkedJobs){
$linkedjobobjects = (Get-VBRJob | Where-Object {$_.id -eq $job.LinkedJobs.LinkedJobID}) | Get-VBRJobObject
}
You'll initialize some array and add the $linkedjobobjects to the array and then you can sum it along with the items returned by Get-VBRJobObject.