PowerShell script exchange
Post Reply
Unreliably-Recurring
Influencer
Posts: 24
Liked: 4 times
Joined: Jun 05, 2018 7:08 pm
Contact:

AWS VTL - Exporting IsFull from Slot

Post by Unreliably-Recurring »

I want try to and minimize our active maintenance of our AWS VTL.
I'm a total Powershell newbie, and am having a heckofa time getting helpful info from the PowerShell Reference and consistent results from the Veeam PowerShell Toolkit.

What is the script for seeing Full tapes that are in a Slot?

We have a Media Pool named "AWS".
Running

Code: Select all

Get-VBRTapeMedium -MediaPool 'AWS'
returns all of the information that I should need in order to do what I want: IsFull and Location.

BUT running

Code: Select all

Get-VBRTapeMedium -MediaPool 'AWS' | Where-Object {$_.IsFull -eq 'True'} | Export-VBRTapeMedium
tells B&R to waste time trying to, and log Warnings about being unable to, export already-exported tapes.

Ok. So, then, I want to see only Full tapes that are in a Slot.
The B&R console shows 19 of those.
https://stackoverflow.com/questions/246 ... -statement says that the correct way to format my Where-Object with "and"s should probably be

Code: Select all

Get-VBRTapeMedium -MediaPool 'AWS' | Where-Object {( $_.IsFull –eq 'True' –and $_.Location -eq 'Slot')}
The script doesn’t work, so I try and simplify by running

Code: Select all

Get-VBRTapeMedium -MediaPool 'AWS' | Where-Object {$_.Location -eq 'Slot'}
or

Code: Select all

Get-VBRTapeMedium -MediaPool 'AWS' | Where-Object {$_.Location -eq "Slot"}
Both return nothing.

What is the script for seeing Full tapes that are in a Slot?
Thank you.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: AWS VTL - Exporting IsFull from Slot

Post by oleg.feoktistov » 1 person likes this post

Hi @Unreliably-Recurring,

You are on the right track.
First, if a property keeps boolean value, you cannot parse it by a value of string type (use $true instead of 'True').
Second, Location property holds a whole object, so you need to access it one level down to parse it by 'Slot' type.
To sum up, we should have:

Code: Select all

Get-VBRTapeMedium -MediaPool 'AWS' | Where-Object {$_.IsFull -eq $true -and $_.Location.Type -eq 'Slot'}
Cheers!
Oleg
Unreliably-Recurring
Influencer
Posts: 24
Liked: 4 times
Joined: Jun 05, 2018 7:08 pm
Contact:

Re: AWS VTL - Exporting IsFull from Slot

Post by Unreliably-Recurring »

Thank you. That gets the expected result.
The property data type flub is definitely a PowerShell newbie problem.
Second, Location property holds a whole object, so you need to access it one level down to parse it by 'Slot' type.
Where do I find more info about that?
Searching the PowerShell Reference and the Help Center for ".Location" both return no results, and Example 6: Use multiple conditions on Microsoft's Where-Object PowerShell reference doesn't include examples for this way either.

Again, thank you.
jhoughes
Veeam Vanguard
Posts: 282
Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: AWS VTL - Exporting IsFull from Slot

Post by jhoughes » 1 person likes this post

The easiest way is to start with Get-Member:

Code: Select all

Get-VBRTapeMedium -MediaPool 'AWS' | Get-Member
You'll see that the property isn't a simple type, such as a string/int/DateTime.

You can also utilize a handy cmdlet called 'Show-Object' (it's within the PowerShellCookbook module found on the PSGallery). That will allow you to much more easily discover what's in the objects that you are working with by doing this:

Code: Select all

Get-VBRTapeMedium -MediaPool 'AWS' | Show-Object
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
Unreliably-Recurring
Influencer
Posts: 24
Liked: 4 times
Joined: Jun 05, 2018 7:08 pm
Contact:

Re: AWS VTL - Exporting IsFull from Slot

Post by Unreliably-Recurring »

Thank you.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 8 guests