PowerShell script exchange
Post Reply
ccatlett1984
Enthusiast
Posts: 83
Liked: 9 times
Joined: Oct 31, 2013 5:11 pm
Full Name: Chris Catlett
Contact:

FIX Get-VBRSession cmdlet in v9

Post by ccatlett1984 »

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

Re: FIX Get-VBRSession cmdlet in v9

Post by veremin »

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.
ccatlett1984
Enthusiast
Posts: 83
Liked: 9 times
Joined: Oct 31, 2013 5:11 pm
Full Name: Chris Catlett
Contact:

Re: FIX Get-VBRSession cmdlet in v9

Post by ccatlett1984 »

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

Re: FIX Get-VBRSession cmdlet in v9

Post by veremin »

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.
ccatlett1984
Enthusiast
Posts: 83
Liked: 9 times
Joined: Oct 31, 2013 5:11 pm
Full Name: Chris Catlett
Contact:

Re: FIX Get-VBRSession cmdlet in v9

Post by ccatlett1984 »

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

Re: FIX Get-VBRSession cmdlet in v9

Post by veremin »

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.
tsightler
VP, Product Management
Posts: 6009
Liked: 2843 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: FIX Get-VBRSession cmdlet in v9

Post by tsightler »

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

Re: FIX Get-VBRSession cmdlet in v9

Post by veremin »

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

Who is online

Users browsing this forum: No registered users and 23 guests