Retention Restore Age Report

Userlevel 5
Badge +3

Hopefully not spam, but occasionally I’ll see questions from Support Cases on “Can we do X with Powershell” and it gets my interest enough that I like to pump out a quick script as proof of concept.

As a quick reminder, Veeam Support does not produce custom code on demand, so cases aren’t the right route for getting help with scripts or ideas. Such requests are routed to the forums for assistance.

But, I’d feel bad not sharing the results of my curiosity as maybe someone would find it useful.



We ended up with a case where a client wanted to help gauge where they should keep their retention at based on the average age of restore requests. This is a great and proactive question and I really liked the idea of checking one’s retention policies against real-world use in their environment.

VeeamOne has a great report for this already with the Restore Operator Activity, and I recommend you use that if you are licensed for VeeamOne.


If not however, this is fairly fast and easy script to implement:

$restoreSess = Get-VBRRestoreSession
$restoredata = @()
foreach($r in $restoreSess){
$restoreInfo = [ordered]@{
Name = $r.Name
RestoreDate = $r.CreationTime
RestorePoint = $r.Info.OibCreationTime
RequestAge = ($r.Creationtime - $r.Info.OibCreationTime).Days
$restoreAgeStats = New-Object psobject -Property $restoreInfo
$restoredata += $restoreAgeStats

$restoreData is okay to have as an array if you’re working in a smaller environment, but for larger environments, you’ll want to use a List instead and use the Add() method to build the List instead. Simply add:


using namespace System.Collections.Generic

and when initializing the list, you’ll do:

$restoredata = [List[Object]]@()

This is because the Add() method is much more memory friendly and performant for larger environments.

Note we set [ordered] on the customObject because otherwise objects returned from a hash are ordered randomly so it makes the report ugly.


End result will be something like:

Name                                        RestoreDate         RestorePoint        RequestAge----                                        -----------         ------------        ----------
SQL Server database restore (DDom-sql-test) 7/18/2022 15:50:06  11/17/2021 12:40:08        243
FLR_[DDom-sql-test]                         7/18/2022 15:49:33  11/17/2021 12:40:08        243
SQL Server database restore (DDom-sql-test) 7/18/2022 13:01:17  11/17/2021 12:40:08        243
SQL Server database restore (DDom-sql-test) 7/18/2022 12:57:14  11/17/2021 12:40:08        243
FLR_[DDom-sql-test]                         7/18/2022 12:51:41  11/17/2021 12:40:08        243
FLR_[ddom-multidisk-tester]                 7/15/2022 16:32:14  4/28/2021 18:30:18         442

You can add properties from the CRestoreSession object like JobType to help on filtering and export the resulting data to CSV or some other format for your reporting purposes/filtering.

Powershell can do some really nifty things with Veeam and make your future planning very easy and data-driven.

Hope it helps someone out.




Userlevel 7
Badge +17

Nice script 😎👍🏼 Thank you

Userlevel 7
Badge +20

Yes very handy script to put in my collection.  😁

Userlevel 7
Badge +20

@ddomask this is, in a word: AWESOME.


You should add this to VeeamHub 😁

Userlevel 7
Badge +14

Most of the time the question is not about if, but rather about how can I do this with PowerShell. I think there's nothing you can't achieve with it 😅