Reputation: 5421
What is the most convenient way to 'and' together a pipeline, such that the returned value is true iff every incoming object evaluated to true? Such as:
$fileList | % { Test-Path $_ } | Boolean-And
The above snippet should be testing that every file in fileList exists. But there is no 'Boolean-And' function. Is there a different name/way to do this?
Upvotes: 1
Views: 435
Reputation: 68331
Another possibility:
@($fileList | % { Test-Path $_ }) -notcontains $false
As a pipeline function:
function And-Boolean
{ $input -notcontains $false }
Upvotes: 3