PowerShell script exchange
Post Reply
meelisn
Influencer
Posts: 17
Liked: never
Joined: Jun 09, 2020 2:21 pm
Full Name: Meelis Nigols
Contact:

Get-VBRComputerBackupJobSession takes very long time

Post by meelisn »

I would like to get information about Agent backup jobs, like completion result and creation time of last session. I know that I can use Get-VBRComputerBackupJobSession.

The problem is that this command takes 20 seconds to obtain 17636 job sessions (for only 1 agent job). The whole script takes 24 seconds to run and this is too long.

Would it be somehow possible to take only latest session of specific job?
meelisn
Influencer
Posts: 17
Liked: never
Joined: Jun 09, 2020 2:21 pm
Full Name: Meelis Nigols
Contact:

Re: Get-VBRComputerBackupJobSession takes very long time

Post by meelisn »

using following variants takes still 18 seconds:

Code: Select all

(Get-VBRComputerBackupJobSession -Name 'job name') | Select-Object -First 1
(Get-VBRComputerBackupJobSession -Name 'job name')[0]
and parentheses are required because the command returns boxed object (counting object in pipeline returns 1 object).
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Get-VBRComputerBackupJobSession takes very long time

Post by david.domask »

Hi @meelisn,

TBH, it's fairly fast for 17k sessions to be processed from the DB to Powershell output. I get that the idea is that you just want the last session and not all 17k sessions, but in fact it's pretty fast.

As a workaround that's technically still supported, fetch the Agent job with Get-VBRJob -WarningAction SilentlyContinue (else it will warn you about deprecated use of command).

CJob Objects have a FindLastSession() method that you can use. Note that such internal methods are not supported, so the behavior might change a bit.

I guess it just makes sense to make a request for a -MostRecent filter on the Session cmdlets for the most common requests like that. I'll do that internally for you, as it makes sense. Of course, I cannot comment on if/when it would be implemented.
David Domask | Product Management: Principal Analyst
meelisn
Influencer
Posts: 17
Liked: never
Joined: Jun 09, 2020 2:21 pm
Full Name: Meelis Nigols
Contact:

Re: Get-VBRComputerBackupJobSession takes very long time

Post by meelisn »

I guess it just makes sense to make a request for a -MostRecent filter on the Session cmdlets for the most common requests like that. I'll do that internally for you, as it makes sense. Of course, I cannot comment on if/when it would be implemented.
That would be nice.

Meanwhile, I'll try FindLastSession(), maybe that helps.
meelisn
Influencer
Posts: 17
Liked: never
Joined: Jun 09, 2020 2:21 pm
Full Name: Meelis Nigols
Contact:

Re: Get-VBRComputerBackupJobSession takes very long time

Post by meelisn »

Meanwhile, I'll try FindLastSession(), maybe that helps.
That works well right now. But as Get-VBRJob is deprecated on agent jobs, this approach will go away. How long can I assume that Get-VBRJob will return agent jobs?
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Get-VBRComputerBackupJobSession takes very long time

Post by david.domask »

Glad to hear it works.

To be honest, I cannot answer your question as I'm just not sure what plans there are for advanced filtering on the *Session cmdlets. Consider this topic a feature request (I'll raise internally also).
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests