Rabu, 01 Juni 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.

lamsim

About lamsim

Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.

Subscribe to this Blog via Email :