Hi
@WienerHausberge,
I think I get what you're going for.
I'll leave the formatting/editing of the table data up to you, but I'd try it like this:
Code: Select all
function Get-VBRStorageFileStats {
param(
[Veeam.Backup.Core.COib]$rp
)
$FileStats = $rp.FindStorage().Stats.BackupSize
Return $FileStats
}
$Backups = Get-VBRBackup
$ReportData = @()
ForEach($b in $Backups){
$JobName = $b.JobName
$JobType = $b.JobType
$RestorePoints = Get-VBRRestorePoint -Backup $b | Sort-Object -Property CreationTime -Descending
Foreach($r in $RestorePoints){
$storageSize = Get-VBRStorageFileStats -rp $r
$BackupData = [PSCustomObject] @{
JobName = $JobName
JobType = $JobType
MachineName = $r.Name
BackupFileSize = $storageSize
RestorePointDate = $r.CreationTime
}
$ReportData += $BackupData
}
}
You can see an example output here:
Code: Select all
PS C:\Program Files\Veeam\Backup and Replication\Backup> $ReportData|Format-Table
JobName JobType MachineName BackupFileSize RestorePointDate
------- ------- ----------- -------------- ----------------
ps-test-agent EpAgentBackup DDOM-VEEAM-RB4 3301376 2/28/2023 3:26:05 PM
ps-test-agent EpAgentBackup DDOM-VEEAM-RB4 3825664 2/24/2023 1:46:05 PM
gfs-test_clone1 BackupSync DDom-TinyVM_replica 2228224 1/30/2023 10:01:45 PM
gfs-test_clone1 BackupSync ddom-tinyvm 2228224 1/30/2023 10:00:47 PM
gfs-test_clone1 BackupSync DDom-TinyVM_replica 2199552 1/26/2023 10:01:49 PM
gfs-test_clone1 BackupSync ddom-tinyvm 2199552 1/26/2023 10:00:46 PM
gfs-test_clone1 BackupSync DDom-TinyVM_replica 2224128 1/26/2023 7:50:09 PM
gfs-test_clone1 BackupSync ddom-tinyvm 2224128 1/26/2023 8:01:36 AM
Backup Copy Job 2 SimpleBackupCopyPolicy SKur-linux-dummy-1 814661405 2/20/2023 5:11:25 PM
ddom-tinyvm_2022-11-24_2025-11-24 Backup ddom-tinyvm 1634304 11/24/2022 8:01:28 AM
Few comments:
1. I left the BackupFileSize in bytes because I test with tiny VMs (Thin Disk machines with no actual OS), you will want to change the line with BackupFileSize = $storageSize to be like:
BackupFileSize = $storageSize/1GB
That will display it in Gigabytes; Terabytes and so on are similar syntax. I change it in the PSCustomObject as I want to keep the original data intact in case you want to edit the script.
2. Right now it's a bit verbose on the output as I'm not sure what else you want
You can add properties (or remove) on the PSCustomObject to your heart's desire.
3. My framework above is suitable for output to CSV with Export-CSV cmdlet in Powershell; it's convenient to export it to other systems easily. Export-JSON should work also here.
4. I break out the StorageSize format into a function as it's easier to edit, and for any other properties where you need to call another cmdlet or method to get the data, I advise do it there too. This also means that if some backup objects maybe have properties other's don't, it's a lot easier/cleaner to introduce a meaningful IF statement to only run the function on those objects.
I'm not confident I hit everything you wanted, and I know the framework's basic output likely isn't formatted as pretty as you want, but if you have troubles getting it to look like you're hoping, just update and we can help