PowerShell script exchange
Post Reply
b.vanhaastrecht
Service Provider
Posts: 880
Liked: 164 times
Joined: Aug 26, 2013 7:46 am
Full Name: Bastiaan van Haastrecht
Location: The Netherlands
Contact:

Getting last lape session status

Post by b.vanhaastrecht »

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, Service Provider and a proud Veeam Legend
veremin
Product Manager
Posts: 20408
Liked: 2299 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Getting last lape session status

Post by veremin »

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.
veremin
Product Manager
Posts: 20408
Liked: 2299 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Getting last lape session status

Post by veremin »

A tape job entity also has LastState and LastResult parameters that can be used in this case. Thanks.
b.vanhaastrecht
Service Provider
Posts: 880
Liked: 164 times
Joined: Aug 26, 2013 7:46 am
Full Name: Bastiaan van Haastrecht
Location: The Netherlands
Contact:

Re: Getting last lape session status

Post by b.vanhaastrecht »

$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, Service Provider and a proud Veeam Legend
veremin
Product Manager
Posts: 20408
Liked: 2299 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Getting last lape session status

Post by veremin »

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.
b.vanhaastrecht
Service Provider
Posts: 880
Liked: 164 times
Joined: Aug 26, 2013 7:46 am
Full Name: Bastiaan van Haastrecht
Location: The Netherlands
Contact:

Re: Getting last lape session status

Post by b.vanhaastrecht »

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, Service Provider and a proud Veeam Legend
veremin
Product Manager
Posts: 20408
Liked: 2299 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Getting last lape session status

Post by veremin »

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.
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests