Getting last lape session status

PowerShell script exchange

Getting last lape session status

Veeam Logoby b.vanhaastrecht » Fri May 13, 2016 7:01 am

Hi,

From v8 the session status of a tape job has moved to Get-VBRSession. However this new CMDlet lacks the functions we had like LastState, LastResult, LastSession ext. They are now fetchable by arguments.

Why o why is there a difference in approach in getting session information from a 'normal' job and a tape job? This make's programming unlogical... :roll: I need to make an version chech to make the script complaint against multiple versions... grrr.

Regards,
Bastiaan
========================================
Veeam ProPartner and Cloud Connect Provider
b.vanhaastrecht
Service Provider
 
Posts: 335
Liked: 65 times
Joined: Mon Aug 26, 2013 7:46 am
Location: The Netherlands
Full Name: Bastiaan van Haastrecht

Re: Getting last lape session status

Veeam Logoby v.Eremin » Tue May 17, 2016 1:59 pm

I'm not quite following you on that.

The said cmdlet returns VBRBackupSession object that has Result and State properties. Those contain the information you're looking for.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Getting last lape session status

Veeam Logoby v.Eremin » Tue May 17, 2016 3:31 pm

A tape job entity also has LastState and LastResult parameters that can be used in this case. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Getting last lape session status

Veeam Logoby b.vanhaastrecht » Wed May 18, 2016 2:29 pm

$job=(Get-VBRJob -name $job_name)
$tapejob=(Get-VBRTapeJob -name $job_name)

$job.GetLastResult
$job.GetLastState

$tapejob.LastResult
$tapejob.LastState

And

$job_session=$job.FindLastSession(); #FindLastSession is not there on tape jobs
$tape_session = Get-VBRSession -Job $tapejob -Last #need to do it like this

It works offcourse, but one and the same approach for all job type's is preferabele.

The name Get-VBRSession is misleading, it's only for tape jobs so why Veeam didn't name it Get-VBRTapeSession is :roll:
========================================
Veeam ProPartner and Cloud Connect Provider
b.vanhaastrecht
Service Provider
 
Posts: 335
Liked: 65 times
Joined: Mon Aug 26, 2013 7:46 am
Location: The Netherlands
Full Name: Bastiaan van Haastrecht

Re: Getting last lape session status

Veeam Logoby v.Eremin » Fri May 20, 2016 5:39 pm

GetLastResult() is dynamic method, while LastResult is static property. Thus, the difference.

While working on PS model for tape functionality, we decided to stick to MS best practices that recommend avoiding usage of dynamic methods on PS objects.

As Get-VBRSession commandlet, we're planning to expand it further in order for it to include sessions of types different than tape one.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Getting last lape session status

Veeam Logoby b.vanhaastrecht » Mon May 23, 2016 8:33 am

Would be very nice if the Get-VBRSession would scope all job types.

And a free tip, work with deprecated warnings with one version in between so we have some time to adjust our scripts accordingly. :idea:
========================================
Veeam ProPartner and Cloud Connect Provider
b.vanhaastrecht
Service Provider
 
Posts: 335
Liked: 65 times
Joined: Mon Aug 26, 2013 7:46 am
Location: The Netherlands
Full Name: Bastiaan van Haastrecht

Re: Getting last lape session status

Veeam Logoby v.Eremin » Mon May 23, 2016 10:45 am

We already try to follow the suggested practice at least with commandlets.

However, the internal properties and methods change inside product db with every product version. And it's not possible to preserve two versions in this case.

Anyway, thank you for the feedback; appreciated.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 2 guests