Skip to main content

Hey all,

Again, hope it’s not spam, but wanted to share some custom code that came up for the purpose of a case and let the community have it also (since why not?)

Issue:

  • You want to have an inventory of
    • Current Tape Locations
    • Library Association
    • Other Tape Elements

There isn’t really a “nice” VeeamOne report for this (vOne just reports on Vaulted Tapes), and checking the tape WebUI isn’t always convenient nor is checking the Veeam Tape node.

If you find a need for this, check this out:

using namespace System.Collections.Generic
function Get-VBRTapesInLibrary {
param(
mVeeam.Backup.PowerShell.Infos.VBRTapeLibrarya]]$Library
)
$TapesInLibrary = Get-VBRTapeMedium | Where-Object {$_.LibraryID -eq $Library.id}
return $TapesInLibrary
}

function New-TapeLocationPropertiesObject {
param(
mVeeam.Backup.PowerShell.Infos.VBRTapeMediumT]]$tapemedium
)
$TapeBarcode = $tapemedium.Barcode
$TapeName = $tapemedium.Name
$TapeLocation = $tapemedium.Location.Type
if($tapemedium.Location.Type -eq "Drive"){
$LocationAddress = ($Drives | Where-Object {$_.id -eq $tapemedium.Location.DriveID}).Name
} else {
$LocationAddress = $tapemedium.Location.SlotAddress
}
$TapeLibrary = $Libraries | Where-Object {$_.id -eq $tapemedium.LibraryID}
$TapeObjectProperties = pPSCustomObject]@{
TapeBarcode = $TapeBarcode
TapeName = $TapeName
TapeLocation = $TapeLocation
LocationAddress = $LocationAddress
TapeLibrary = $TapeLibrary.Name
}
return $TapeObjectProperties
}


$Libraries = Get-VBRTapeLibrary
$Drives = Get-VBRTapeDrive
$LibraryInventory = vListrObject]]@()
Foreach($tl in $Libraries){
$TapesInLibrary = Get-VBRTapesInLibrary -Library $tl
Foreach($tape in $TapesInLibrary){
$TapeProperties = New-TapeLocationPropertiesObject -tapemedium $tape
$LibraryInventory.Add($TapeProperties)
}
}

$LibraryInventory | Export-Csv -NoTypeInformation -Path C:\temp\TapeLibraryInventoryReport.csv

You can add properties from  Veeam.Backup.PowerShell.Infos.VBRTapeMedium objects to the function New-TapeLocationPropertiesObject as you desire. Vaulting information should be there also to help track it, but the above is a simple example on how to build this for easy tracking. 

Naturally this will not give you the _contents_ of tapes, but I know it’s not uncommon to have such reports that can be moved to various reporting services.

Change out the Export-CSV to whatever you desire/need for your reporting (e.g., use ConvertTo-JSON if you need JSON, or write a function for other mark-up languages)

Hope someone finds this useful!

 

Example CSV output:

 

"TapeBarcode","TapeName","TapeLocation","LocationAddress","TapeLibrary"
"newt08L3","newt08L3","Slot","7","hp-library"
"newi01L3","newi01L3","Slot","17","hp-library"
"newt02L3","newt02L3","Slot","9","hp-library"
"worm01","worm01","Slot","6","hp-library"
"emp","emp","Drive","Tape4","hp-library"

Interesting. Such reports are indeed missing and it is very useful if you are doing some kind of vaulting.


Any scripts to benefit the community is not spam.  Thanks for sharing as these are always great to have.


Comment