FIX Get-VBRSession cmdlet in v9

PowerShell script exchange

FIX Get-VBRSession cmdlet in v9

Veeam Logoby ccatlett1984 » Wed Aug 17, 2016 6:22 pm

Case #01882938


(For Disk & Copy Sessions)
Get-VBRBackupSession does not require you to specify a job name to look up sessions.

(For Tape Sessions)
Get-VBRSession (why is it not Get-VBRTapeSession ??) requires you to specify a job.

Whats worse, is that you can't pipe Get-VBRTapeJob to Get-VBRSession....
Get-VBRTapeJob returns the "job name" as the 'Name' property
Get-VBRSession expects it to be in the 'Job' property

Its looking for a property with a type of "Veeam.Backup.PowerShell.Infos.VBRJob", so I can't even use an expression to fix the naming.
ccatlett1984
Enthusiast
 
Posts: 83
Liked: 9 times
Joined: Thu Oct 31, 2013 5:11 pm
Full Name: Chris Catlett

Re: FIX Get-VBRSession cmdlet in v9

Veeam Logoby v.Eremin » Wed Aug 17, 2016 6:36 pm

Get-VBRSession requires you to specify a job.

It's an expected behaviour, indeed.

why is it not Get-VBRTapeSession ?

We plan to expand its capabilities down the road. Thus, the general name.

Whats worse, is that you can't pipe Get-VBRTapeJob to Get-VBRSession....

This one doesn't look expected. Let me double check that internally.

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

Re: FIX Get-VBRSession cmdlet in v9

Veeam Logoby ccatlett1984 » Wed Aug 17, 2016 7:05 pm

Thanks for the quick reply, I'm alright with the generalized naming and the need to specify a job (so long as I can pipe to it.)

I'm trying to use this for some custom reporting I do through powershell, and need to get the most recent tape session for each job (since the job object doesn't store the last time it was executed, even though it stores the result.)
ccatlett1984
Enthusiast
 
Posts: 83
Liked: 9 times
Joined: Thu Oct 31, 2013 5:11 pm
Full Name: Chris Catlett

Re: FIX Get-VBRSession cmdlet in v9

Veeam Logoby v.Eremin » Wed Aug 17, 2016 7:23 pm

Hmm, may be this example can help you a bit:

Code: Select all
foreach ($TapeJob in (Get-VBRTapeJob))
{
Get-VBRSession -Job  $TapeJob -Last | select -Property @{N="Name"; E={((Get-VBRTapeJob) | where {$_.Id -eq $TapeJob.id}).name}}, @{N="Result"; E={$_.Result}}, @{N="EndTime"; E={$_.EndTime}}
}


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

Re: FIX Get-VBRSession cmdlet in v9

Veeam Logoby ccatlett1984 » Wed Aug 17, 2016 7:53 pm

Doesn't work for "continuous jobs", they show an 'endtime' of 1/1/1900

Also the below is much more efficient:
Code: Select all
$jobs = Get-VBRTapeJob

$colinfo = @()
foreach ($TapeJob in $jobs)
{
$info = Get-VBRSession -Job  $TapeJob -Last | select -Property @{N="Name"; E={($jobs | where {$_.Id -eq $TapeJob.id}).name}}, @{N="Result"; E={$_.Result}}, @{N="EndTime"; E={$_.EndTime}}
$colinfo +=$info
}
ccatlett1984
Enthusiast
 
Posts: 83
Liked: 9 times
Joined: Thu Oct 31, 2013 5:11 pm
Full Name: Chris Catlett

Re: FIX Get-VBRSession cmdlet in v9

Veeam Logoby v.Eremin » Thu Aug 18, 2016 9:32 am

Not sure how the provided script is much more efficient since the only difference it has compared to the previously posted example is the fact that it saves the result to a variable. Anyway, it's up to you to leverage whatever one you want to. Thanks.
v.Eremin
Veeam Software
 
Posts: 13295
Liked: 973 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: FIX Get-VBRSession cmdlet in v9

Veeam Logoby tsightler » Thu Aug 18, 2016 2:46 pm

v.Eremin wrote:Not sure how the provided script is much more efficient since the only difference it has compared to the previously posted example is the fact that it saves the result to a variable. Anyway, it's up to you to leverage whatever one you want to. Thanks.

Not having to call Get-VBRTapeJob in the pipe output is likely quite a big boost in efficiency, especially in a large environment. Even better would be store the initial result in a hash table and cycle over the hashes, which would pipe only the minimum needed during each loop, but now we're getting way off topic. :D
tsightler
Veeam Software
 
Posts: 4773
Liked: 1740 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: FIX Get-VBRSession cmdlet in v9

Veeam Logoby v.Eremin » Thu Aug 18, 2016 2:52 pm

Ahh, almost always forget about that aspect and the fact that there are infrastructures with more than one library and more than two tape jobs. :D
v.Eremin
Veeam Software
 
Posts: 13295
Liked: 973 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 8 guests