Solved

Using Powershell to query for online only tapes

  • 29 November 2023
  • 3 comments
  • 133 views

Userlevel 4
Badge

Hello. We have a policy to export all tapes currently in a library that are marked FULL. I can get a list of all FULL tapes in a media pool like this:


[String] $LibraryName         = Get-VBRTapeLibrary | Select -Expandproperty Name
$TapesToBeEjected     = Get-VBRTapeMedium -Library $LibraryName | Where {$_.IsFull -eq "TRUE"} | Select Name, LastWriteTime, MediaPoolID | Sort -Property Name
 

(there’s more to my script, but that is the relevant querying section)

 

However, that gives me *all* tapes in the pool that are FULL, and I want only the tapes in a pool that are currently ONLINE in a library that are FULL (so it can send an email to the tape operators and tell them to go export the tape(s)). And I have not found a way to do that - I don’t see any property that is returned that shows ONLINE or OFFLINE of a specific tape. Am I just missing it? Is there way to query for this, so I can send an alert email (as a scheduled task)? Or is there some other way to do it? (we don’t have a license for Veeam ONE). This is VBR 12.0.

 

Thanks for any help.

 

icon

Best answer by JMeixner 29 November 2023, 20:30

View original

3 comments

Userlevel 7
Badge +17

You can check the location parameter of each tape.

Online tapes have a location type of “Slot” or “Drive”, all others are not in the library.

I got the tape information with Get-VBRTapeMedium

$tape[0]].Location


DriveId      :

DriveAddress :

LibraryId    : xxxxxxxx-yyyy-zzzz-aaaa-bbbbbbbbbbbb

SlotAddress  : 23

VaultId      :

Type         : Slot

Userlevel 4
Badge

You can check the location parameter of each tape.

Online tapes have a location type of “Slot” or “Drive”, all others are not in the library.

I got the tape information with Get-VBRTapeMedium

$tape[0]].Location


DriveId      : DriveAddress : LibraryId    : xxxxxxxx-yyyy-zzzz-aaaa-bbbbbbbbbbbb SlotAddress  : 23 VaultId      : Type         : Slot

AH HA! That’s great. I now have this:

(I had to convert the location to a string, because of the type of property it is. Also, I try to write it so my co-workers, who aren’t good at scripting, can at least follow along, even if it’s not the most efficient programming code)

        $TapeIsFull                        = $Tape.IsFull
        [String] $TapeLocation        = $Tape.Location
        $TapeIsOffSite                    = ($TapeLocation -eq "None")
        IF ((-not $TapeIsOffSite) -and ($TapeIsFull)) {
 

But that’s what I’m looking for!

 

Thanks!

Userlevel 7
Badge +17

You are welcome.

I think I have read that you can set the location value by yourself, so you can keep track of your tapes. But I haven't tried it yet, therefore without guarantee...

 

Comment