marcohorstmann / MyVeeamReport

20 stars 1 forks source link

Total for Backup Job Size? #9

Open marcohorstmann opened 1 year ago

marcohorstmann commented 1 year ago

From Shawns Blog: I was looking for a way to add totals to the Get Backup Job Size. I came up with the following code that adds totals in, but it is not the cleanest method. Thought maybe you have a better way to do this.


# Get Backup Job Size
$bodyJobSizeBk = $null
$bodyJobSizeBkt = $null
$vmcount = $null
$vmdatasize = $null
$vmbackupsize = $null
If ($showBackupSizeBk) {
If ($backupsBk.count -gt 0) {
$bodyJobSizeBk = Get-BackupSize -backups $backupsBk | Sort JobName | Select @{Name=”Job Name”; Expression = {$_.JobName}},
@{Name=”VM Count”; Expression = {$_.VMCount}},
@{Name=”Repository”; Expression = {$_.Repo}},
@{Name=”Data Size (GB)”; Expression = {$_.DataSize}},
@{Name=”Backup Size (GB)”; Expression = {$_.BackupSize}} #| ConvertTo-HTML -Fragment

Get-BackupSize -backups $backupsBk | Sort JobName | ForEach {
$vmcount += $_.VMCount
$vmdatasize += $_.DataSize
$vmbackupsize += $_.BackupSize
}
$bodyJobSizeBkt = Get-BackupSize -backups $backupsBk | Select @{Name=”Job Name”; Expression = {“Total”}},
@{Name=”VM Count”; Expression = {$vmcount}},
@{Name=”Repository”; Expression = {$null}},
@{Name=”Data Size (GB)”; Expression = {$vmdatasize}},
@{Name=”Backup Size (GB)”; Expression = {$vmbackupsize}} -Unique #| ConvertTo-HTML -Fragment
$bodyJobSizeBk = $bodyJobSizeBk + $bodyJobSizeBkt | ConvertTo-HTML -Fragment
$bodyJobSizeBk = $subHead01 + “Backup Job Size” + $subHead02 + $bodyJobSizeBk
}

}