PowerShell script exchange
Post Reply
rootxps
Lurker
Posts: 1
Liked: never
Joined: Jan 05, 2021 1:34 pm
Full Name: Jimmy
Contact:

Displaying specific Tape Barcodes

Post by rootxps »

Hello,

i'm looking for a way to output the Barcodes from the last Monthly Tape Backup in GFS-Mediapool. For example: Monthly Backup to Tape Job runs at first Sunday in Month. If i start the Script on 11. February (Or any other Day after first Sunday in Month) and the Monthly Tapes from first Sunday of February are still online, the Script should tell me the Barcode from that monthly Tapes, so i can export them. If i start the Script on 11. February and there are no Monthly Backup Tapes from February online but from January, the script should give me the Barcodes from the January Tapes.

I tried to solve this with the "Get-VBRTapeMedium | where object" output in PowerShell, but there is no "online" Value, any Ideas?

Thank you!
soncscy
Veteran
Posts: 643
Liked: 312 times
Joined: Aug 04, 2019 2:57 pm
Full Name: Harvey
Contact:

Re: Displaying specific Tape Barcodes

Post by soncscy »

Hey Jimmy,

I am hopeful there's a cleaner way to do this, but I was able to hack out a way with reflections in powershell. Probably this isn't stable though and you'll need to remake it for each version, but you can feed a given session ID to CBaseSession and get the data from the AuxData property. It's in XML format, so just force an XML type and the output is quite pretty.

Fetch a desired session with Get-VBRSession and save it to some variable (in my example, I sorted all session by creation time descending so I need to do $($thing.action) in order to make PS return the ID there, you can just save the session id earlier to have less ugliness), then:

PS C:\Users\Administrator> $sess = [Veeam.backup.Core.CBaseSession]::Get("$($sortedsess[0].id)")
PS C:\Users\Administrator> [xml]$sessdata = $sess.Auxdata
PS C:\Users\Administrator> $sessdata.TapeAuxData.TapeMediums.TapeMedium

Barcode Name Id
------- ---- --
gfstp1L7 gfstp1L7 89ce0704-dde0-487b-a577-7428b33b8768

It's really pretty output I think and should work for your needs. But getting there is kind of ugly :D
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests