PowerShell script exchange
Post Reply
MikeLeone
Enthusiast
Posts: 26
Liked: 2 times
Joined: Sep 21, 2022 3:03 pm
Full Name: Michael Leone
Contact:

Get list of all tapes currently in library (slots and drives)

Post by MikeLeone »

I need to write a report about tapes that currently in my library that are FULL. This command, unfortunately, is monumentally slow:

$TapesToBeEjected = Get-VBRTapeMedium -Library $LibraryName | Where {{$_.IsFull -eq $TRUE}} | Select Name, LastWriteTime, MediaPoolID, IsFull, Location | Sort -Property MediaPoolID, Name

So rather than querying the all the tapes (I have over 1300), I figure it will be faster to just query the library for the tapes currently in the slots and drives (that will be about 80). Then I can do the $_.IsFull on just those.

But I am not seeing a command that seems to do that. Is there one, that queries the library and returns tapes in slots and drives?

Otherwise I would have to loop though Get-VBRTapeMedium -Library $LibraryName , select only $_.Location = Slot or Drive, and then re-select for $_.IsFull.
And I don't think that would be materially faster.

Is there a better way to get the info I need?
david.domask
Veeam Software
Posts: 3174
Liked: 735 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Get list of all tapes currently in library (slots and drives)

Post by david.domask »

Hi MikeLeone,

When you say monumentally slow, can you give a time value for this? Please show the output of:

Code: Select all

Measure-Command -Expression {Get-VBRTapeMedium}
Measure-Command -Expression {Get-VBRTapeMedium -Library $LibraryName | Where {{$_.IsFull -eq $TRUE}} | Select Name, LastWriteTime, MediaPoolID, IsFull, Location | Sort -Property MediaPoolID, Name}
(Get-VBRTapeMedium -Library $LibraryName | Where {{$_.IsFull -eq $TRUE}}).Count
Potentially, you could parse through media pools with Get-VBRTapeMediaPool and pull out IsFull from that, but depending on the number of tapes in each media pool that may be slow as well.

Basically, I suspect we may need a case to review the behavior here but would be curious at first to understand how slow is "slow".

Similarly, I'm curious if it works better without the Select / Sort in the same line -- Select will build a PSCustomObject for each item piped to it, and I suspect that this may be the cause of the long-running command, and breaking the pipeline up into separate lines may help.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 20 guests