PowerShell script exchange
Post Reply
Daniel2
Enthusiast
Posts: 45
Liked: 21 times
Joined: Nov 25, 2019 8:16 am
Full Name: Daniel
Contact:

Filter Get-VBRBackupSession before all sessions are retrieved?

Post by Daniel2 »

I need to get the backup sessions of the last 24 hours. I'm currently using Get-VBRBackupSession, which always retrieves close to 10.000 sessions. It takes minutes to complete. Then I filter on sessions where the creationtime is t-24h.

Is there a way to filter the retrieved sessions BEFORE all 10.000 sessions are retrieved?

Using VBR 11
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Filter Get-VBRBackupSession before all sessions are retrieved?

Post by oleg.feoktistov »

Hi Daniel,

No direct and supported way to do that, but you can try the .NET method below:

Code: Select all

$job = Get-VBRJob -Name 'BackupJob'
$fromDate = (Get-Date).AddHours(-24)
$toDate = Get-Date
$sessions = [Veeam.Backup.Core.CBackupSession]::GetAllSessionsByPolicyJobAndTimeRange($job.Id, $fromDate, $toDate)
Instead of getting all sessions at once and filtering them on powershell level, it filters sessions by a time range right on DB query level.

Best regards,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests