Find last used tape

PowerShell script exchange

Find last used tape

Veeam Logoby vdbautsup » Fri Jan 08, 2016 2:03 pm

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
vdbautsup
Lurker
 
Posts: 2
Liked: never
Joined: Fri Jan 08, 2016 1:45 pm

Re: Find last used tape

Veeam Logoby v.Eremin » Fri Jan 08, 2016 2:53 pm

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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Find last used tape

Veeam Logoby vdbautsup » Tue Jan 12, 2016 2:51 pm

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
vdbautsup
Lurker
 
Posts: 2
Liked: never
Joined: Fri Jan 08, 2016 1:45 pm


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 4 guests