PowerShell script exchange
Post Reply
vdbautsup
Lurker
Posts: 2
Liked: never
Joined: Jan 08, 2016 1:45 pm

Find last used tape

Post by vdbautsup »

Hi all,
We used to monitor the amount of tape used in the last job to report about capacity.
Since V8 I'm not able to find the right medium In the past I used the VBRSession.AuxData for this, which now looks depreciated. So far I managed to find the latest job and session with Get-VBRTapeJob and Get-VBRSession, but I cannot find a way to determine which tape was used in this session, in order to retrieve the tape data with Get-VBRTapeMedium. Can anyone help me out with this?
Thanks,
Ad
veremin
Product Manager
Posts: 20284
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Find last used tape

Post by veremin »

If you have a script working with obsolete tape session view and AuxData parameter it used to have, you can still get access to it, using "creative" workaround:

Code: Select all

$Job = Get-VBRTapeJob -Name "Name of tape Job"
$Sessions = [Veeam.Backup.Core.CBackupSession]::GetByJob($Job.id)
Thanks.
vdbautsup
Lurker
Posts: 2
Liked: never
Joined: Jan 08, 2016 1:45 pm

Re: Find last used tape

Post by vdbautsup »

Hi Vladimir,

Thanks, that did the job!
However the Auxdata and the TapeMedium object were a bit different formatted than in V7, I could work around this.

Did it eventually like this:

Code: Select all

switch ($version) {
7 {$session = $job.FindLastSession()}
8 {$session = [Veeam.Backup.Core.CBackupSession]::GetByJob($job.id) | Sort-Object creationtime | select -Last 1}
}
$tapeName = [regex]::Split([regex]::Split($session.AuxData, 'Barcode="" Name="')[1], '"')[0]
if ($tapeName) {
$tape = Get-VBRTapeMedium -Name $tapeName
switch ($version) {
7 {$tapeFreePerc = [Math]::Round($tape.Remaining / $tape.Capacity * 100, 0)}
8 {$tapeFreePerc = [Math]::Round($tape.Free / $tape.Capacity * 100, 0)}
}
}
Regards, thanks again!
Ad
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests