Wednesday, June 1, 2016

PowerShell v2 Multiple Where Filters

,
A couple of years ago I posted this:

Powershell - Multiple Where-Object Filters
As one of the comments noted I needed to look into the conjunctions: -and and -or. Revising this script it should look like this now:
Get-ChildItem -Path C: -Recurse -Include *.txt | Where {($_.Length -eq 0) -and ($_.Mode -eq "-a---")}
The conjunction -and eliminates the need for multiple pipelined where clauses. Knowing what I know now, I cannot think of a single use for what I posted. Just wrap each individual search criteria in parentheses and put -ands between them.

0 comments to “PowerShell v2 Multiple Where Filters”

Post a Comment

 

Computer Info Copyright © 2016 -- Powered by Blogger