Unsure about constructing a compound WHERE clause

3 views
Skip to first unread message

Mike Leone

unread,
Dec 30, 2025, 12:48:08 PM (12 days ago) 12/30/25
to NTPowershell Mailing List
OK, I'm drawing a blank on how to do this. I need to construct a WhERE
clause that looks like this:

Get-VBRTapeMedium -Library $LibraryName | Where {{$_.IsFull -eq $TRUE}
-and ({$_.Location -eq "Slot"} -or {$_.Location -eq "Drive"})}

And it's the $_.Location property I am confused about. I need it to
return any entries where the $.Location property is either "Slot" or
"Drive", and at the same time, the $_.IsFull property is "True".

The above should work, I think. But I seem to be recalling a better
way to specify that either/or condition, in a WhERE clause. And I'm
drawing a blank on how best to re-write this (if any).

Anyone have an idea?

--

Mike. Leone, <mailto:tur...@mike-leone.com>

PGP Fingerprint: 0AA8 DC47 CB63 AE3F C739 6BF9 9AB4 1EF6 5AA5 BCDF
Photo Gallery: <http://www.flickr.com/photos/mikeleonephotos>

Solodow, Damien

unread,
Dec 30, 2025, 12:53:59 PM (12 days ago) 12/30/25
to ntpowe...@googlegroups.com
You should be able to do it with the in comparison operator:
Get-VBRTapeMedium -Library $LibraryName | Where-Object {{$_.IsFull -eq $TRUE} -and {$_.Location -in ('Slot', 'Drive')}}

Damien Solodow
IT Senior Systems Engineer
Gaylor Electric, Inc.
10405 Crosspoint Blvd
Indianapolis, IN. 46256
O: 317.815.3103 | M: 317.506.8521
--
You received this message because you are subscribed to the Google Groups "ntpowershell" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ntpowershell...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ntpowershell/CAHBr%2B%2BhaZOoXP1xOO8q%2BGPQ5w29P6LGbBVAKDN3fuX7dUDR0dg%40mail.gmail.com.

Kurt Buff

unread,
Dec 30, 2025, 1:05:49 PM (12 days ago) 12/30/25
to ntpowe...@googlegroups.com
I think this should work:

Get-VBRTapeMedium -Library $LibraryName | Where { $_.IsFull -eq $TRUE
-and ( $_.Location -eq "Slot" -or $_.Location -eq "Drive" ) }

That's the kind of construct I use in other situations

Kurt

Aakash Shah

unread,
Dec 31, 2025, 4:26:59 AM (12 days ago) 12/31/25
to ntpowe...@googlegroups.com
Note that since $_.IsFull appears to be Boolean you don't need to specify that it's true and can simply use this below (combining Damien and Kurt's approaches too):

Get-VBRTapeMedium -Library $LibraryName | Where-Object { $_.IsFull -and ( $_.Location -in ('Slot', 'Drive') ) }

Also you only want to use curly brackets for the main Where-Object, but not for the other items you've listed inside it.

-Aakash Shah

-----Original Message-----
From: ntpowe...@googlegroups.com <ntpowe...@googlegroups.com> On Behalf Of Mike Leone
Sent: Tuesday, December 30, 2025 9:48 AM
To: NTPowershell Mailing List <ntpowe...@googlegroups.com>
Subject: [ntpowershell] Unsure about constructing a compound WHERE clause

PGP Fingerprint: 0AA8 DC47 CB63 AE3F C739 6BF9 9AB4 1EF6 5AA5 BCDF Photo Gallery: <https://urldefense.com/v3/__http://www.flickr.com/photos/mikeleonephotos__;!!CzAuKJ42GuquVTTmVmPViYEvSg!P2Gys3QnxrNBP44URHgQ6fjkna18BAJ4okLiQU5A75Q9a0063Til85c26Ssox27zwCl57TMkZU5rKjY$ >

--
You received this message because you are subscribed to the Google Groups "ntpowershell" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ntpowershell...@googlegroups.com.
To view this discussion visit https://urldefense.com/v3/__https://groups.google.com/d/msgid/ntpowershell/CAHBr*2B*2BhaZOoXP1xOO8q*2BGPQ5w29P6LGbBVAKDN3fuX7dUDR0dg*40mail.gmail.com__;JSUlJQ!!CzAuKJ42GuquVTTmVmPViYEvSg!P2Gys3QnxrNBP44URHgQ6fjkna18BAJ4okLiQU5A75Q9a0063Til85c26Ssox27zwCl57TMk-tHQaEY$ .
Reply all
Reply to author
Forward
0 new messages