PowerShell script exchange
Post Reply
RubinCompServ
Service Provider
Posts: 413
Liked: 130 times
Joined: Mar 16, 2015 4:00 pm
Full Name: David Rubin
Contact:

Get-VBRBackupSession slow to return a result

Post by RubinCompServ »

When I use the sample code from the Get-VBRBackupSession helpcenter, it takes upwards of 20 seconds to return the single result. This is for a single job that runs once per day. When I try to run this across all of my backup jobs, it takes more than 3 hours to run.

Code: Select all

$job = Get-VBRJob -Name "JOB_NAME"
Get-VBRBackupSession | Where {$_.jobId -eq $job.Id.Guid} | Sort EndTimeUTC -Descending | Select -First 1
Is it just my environments, or is the Get-VBRBackupSession incredibly slow?
david.domask
Veeam Software
Posts: 3283
Liked: 767 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Get-VBRBackupSession slow to return a result

Post by david.domask »

Hi RubinCompServ,

>Is it just my environments, or is the Get-VBRBackupSession incredibly slow?

Unfortunately very much so a situation where "it depends".

Get-VBRBackupSession can indeed be a bit slow as it currently does not allow for filtering without first doing a lot of processing as you can only filter by -Name and -Id

Get-VBRSession has the -Job and -Type parameters, and in my experience these tend to be a bit faster. Additionally, it returns an object with less properties, but typically enough for reporting purposes. And furthermore, if you need the full data like is returned from Get-VBRBackupSession, you can pass an array of UUIDs on the -Id parameter to Get-VBRBackupSession which is quite fast to return results.

As to whether it's just your environment, would be difficult to say without some investigation -- can you do a simple test for me and show the output of the following?

Measure-Command -Expression {$sessTotal = Get-VBRBackupSession}
$sessTotal.Count

This will take awhile to run, but would be curious how long and also how many sessions total you have. If you're not limiting the retained Session History, there may indeed be a large volume of sessions.

I know that doesn't give a direct answer to your question, but regrettably the answer is very much so "it depends".

All in all, for my scripts I've settled on starting with Get-VBRSession and if I need more information, I pass the Ids returned by that to Get-VBRBackupSession, it's typically much faster. In rare cases, I may switch to unsupported .NET methods but would rather avoid that when possible.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 212 guests