PowerShell script exchange
Post Reply
CeeAr
Influencer
Posts: 19
Liked: 2 times
Joined: Sep 17, 2013 1:09 pm
Contact:

V8 Get-VBRTapeJob changed

Post by CeeAr »

Hi,

i was able to get the latest tape backup session with

Code: Select all

$Job = Get-VBRTapeJob -name blablabla
$Session = $Job.FindLastSession()
In V8 the cmdlet changed and doesn't provide "FindLastSession" anymore.

How can i get the last session of a tape backup job?

Code: Select all

Get-VBRSession
looks promising but i cannot get it to run.

Thanks.

Chris
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: V8 Get-VBRTapeJob changed

Post by veremin »

Hi, Chris,

Can you try something like this:

Code: Select all

$BTJ = Get-VBRTapeJob -Name "Name of your backup to tape job"
Get-VBRSession -Job $BTJ 
Thanks.
CeeAr
Influencer
Posts: 19
Liked: 2 times
Joined: Sep 17, 2013 1:09 pm
Contact:

Re: V8 Get-VBRTapeJob changed

Post by CeeAr »

Thank you Vladimir that works!
I stuck on the next step.

V7 :

Code: Select all

$Info = $Session.GetTaskSessions()


Can you help out for V8 ? I've tried without luck:

Code: Select all

 Get-VBRTaskSession -Session $Session
Thanks again
Chris
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: V8 Get-VBRTapeJob changed

Post by veremin »

I think that you can get access to the tasks' log information of the latest job session, using the following code:

Code: Select all

$Session = Get-VBRSession -Job $BTJ | Sort-Object creationtime | Select-Object -Last 1
$Session.Log
Thanks.
CeeAr
Influencer
Posts: 19
Liked: 2 times
Joined: Sep 17, 2013 1:09 pm
Contact:

Re: V8 Get-VBRTapeJob changed

Post by CeeAr »

yes, but not for the single tasks. In V7 i was able to get more information like speed and bottleneck and check for each backup-to-disc-job that includes this backup-to-tape-job
My tape backup job copies all (5) backup to disk job to tape. I wanna get detailed information for each job and i was able to get that with V7 and powershell.

I think i'm looking for "Get-VBRTaskSession" for tape backup jobs :)

Thank you
Chris
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: V8 Get-VBRTapeJob changed

Post by veremin »

You can try to implement the following workaround:

Code: Select all

$BTJ = Get-VBRTapeJob -Name "Name of backup to tape job"
$BackupSession = [veeam.backup.core.cbackupsession]::GetByJob($BTJ.id)
$BackupSession | Get-VBRTaskSession
However, can you tell me what particular information (parameters, fields) is missing in $Session.Log? I mean the information that is present in TaskSession.

Thanks.
CeeAr
Influencer
Posts: 19
Liked: 2 times
Joined: Sep 17, 2013 1:09 pm
Contact:

Re: V8 Get-VBRTapeJob changed

Post by CeeAr »

Thanks that looks good.

Actually i'm trying to get the same information that are on the html report for each session
Image

...to integrate in an "overall" report. Is there a better way to get these results for tape jobs?


Chris
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: V8 Get-VBRTapeJob changed

Post by veremin »

For now the provided workaround should do the trick. We'll think how existing behaviour can be changed in the next versions, though. Thanks.
bertdhont
Service Provider
Posts: 45
Liked: 5 times
Joined: Nov 08, 2013 2:53 pm
Full Name: Bert D'hont
Contact:

Re: V8 Get-VBRTapeJob changed

Post by bertdhont »

Is there a workaround to use 'Get-VBRTapeJob' in Veeam Standard edition?
In v7 that worked fine. in v8 I get a message:

Get-VBRTapeJob : This functionality is available in the Enterprise (or higher) edition only.
At line:1 char:22
+ $BTJ = Get-VBRTapeJob <<<< -Name "Tape Offload - Weekly"
+ CategoryInfo : NotSpecified: (:) [Get-VBRTapeJob], LicenseException
+ FullyQualifiedErrorId : System.ComponentModel.LicenseException,Veeam.Backup.PowerShell.Cmdlets.GetVBRTapeJob

I used that to stop a session that was waiting for a tape:

Code: Select all

Add-PSSnapin VeeamPSSnapin
Get-VBRTapeJob | ? {$_.GetLastState() -like "WaitingTape"} | Stop-VBRJob
Even in Enterprise version v8, that script doesn't work, because GetLastState() doesn't return the right value...
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: V8 Get-VBRTapeJob changed

Post by veremin »

Hi, Bert,

We've added necessary license restrictions to certain tape commandlets. According to the plane, this behaviour will be fixed in the first patch.

Speaking about .GetLastState method, you can try to use .LastState parameter, instead.

Thanks.
bertdhont
Service Provider
Posts: 45
Liked: 5 times
Joined: Nov 08, 2013 2:53 pm
Full Name: Bert D'hont
Contact:

Re: V8 Get-VBRTapeJob changed

Post by bertdhont »

Is it normal behavior that in PowerShell, you cannot get a Tape Job that is only used for full backup offload?
In the tape job, we did not select the option 'Process incremental backup files'.

In Powerhshell, we get the following error:

Get-VBRTapeJob : Value cannot be null.
Parameter name: incrementalBackupMediaPool
At line:1 char:15
+ Get-VBRTapeJob <<<< -name "Daily Backup - Weekly Tape Offload"
+ CategoryInfo : NotSpecified: (:) [Get-VBRTapeJob], ArgumentNullException
+ FullyQualifiedErrorId : System.ArgumentNullException,Veeam.Backup.PowerShell.Cmdlets.GetVBRTapeJob
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: V8 Get-VBRTapeJob changed

Post by veremin »

So, the whole script looks like:

Code: Select all

Get-VBRTapeJob -name "Daily Backup - Weekly Tape Offload"
And it still fails, even though there is a job named "Daily Backup - Weekly Tape Offload", right?

Thanks.
bertdhont
Service Provider
Posts: 45
Liked: 5 times
Joined: Nov 08, 2013 2:53 pm
Full Name: Bert D'hont
Contact:

Re: V8 Get-VBRTapeJob changed

Post by bertdhont »

Correct.

In the backup job, we only do an offload of the full backups:

Image
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: V8 Get-VBRTapeJob changed

Post by veremin »

Hi, I will ask our QA or dev team to take a look at this behaviour and let you know, once I have more information. Thanks.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: V8 Get-VBRTapeJob changed

Post by veremin »

This confirmed to be a bug and will be fixed in the first patch. Thanks.
pdef
Novice
Posts: 5
Liked: never
Joined: Sep 30, 2014 6:27 am
Contact:

Re: V8 Get-VBRTapeJob changed

Post by pdef »

Veeam BR 8 with Patch 1 installed.

Code: Select all

Get-VBRTapeJob | ? {$_.GetLastState() -like "WaitingTape"} | Stop-VBRJob
Still does not working..

Code: Select all

Get-VBRTapeJob : Value cannot be null.
Parameter name: name
At line:1 char:1
+ Get-VBRTapeJob | ? {$_.GetLastState() -like "WaitingTape"} | Stop-VBRJob
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-VBRTapeJob], ArgumentNullException
    + FullyQualifiedErrorId : System.ArgumentNullException,Veeam.Backup.PowerShell.Cmdlets.GetVBRTapeJob
Does anybody know how to Stop WaitingTape Jobs with Script?
smarechal
Enthusiast
Posts: 56
Liked: 11 times
Joined: Dec 21, 2015 1:23 pm
Full Name: Siegfried
Contact:

Re: V8 Get-VBRTapeJob changed

Post by smarechal » 1 person likes this post

Hi,

Maybe i'm too late:

Code: Select all

Get-VBRTapeJob | Where-Object {$_.LastState -like "WaitingTape"} | Stop-VBRJob
tdewin
Veeam Software
Posts: 1775
Liked: 646 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: V8 Get-VBRTapeJob changed

Post by tdewin »

Seems like the pipeline is not returning anything (meaning no job is waiting). A safer way is to handle this whit foreach. Btw in v9 there seems to be no such function but there seems to be a field called "LastState"

Code: Select all

Get-VBRTapeJob | ? {$_.LastState -like "WaitingTape"} | % { $_ | Stop-VBRJob }
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: V8 Get-VBRTapeJob changed

Post by veremin »

Maybe i'm too late
It's never too late to write a script. :)

And the one proposed by you should work fine, indeed, since starting from version 8 LastState is a static property, not a dynamic method, as it used to be previously.

Thanks.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 21 guests