< Back

Search-Select

Sat Jan 18, 2020 11:29 am

NAME Search-Select



SYNOPSIS

Perform functional-style filter-to-select operations on a sequence or stream of objects in a Powershell pipeline





SYNTAX

Search-Select [-Expression] <ScriptBlock> [-InputObject] <Object[]> [<CommonParameters>]





DESCRIPTION

Apply the given ScriptBlock expression to each member of the pipelined InputObject, selecting those for which the

expression is True.





PARAMETERS

-Expression <ScriptBlock>

The anonymous (in-place) or named (as variable) single-argument lambda function to be applied to each

InputObject element. This must have a single-argument parameter block.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-InputObject <Object[]>

The sequence or stream of Objects from the Powershell pipeline.



Required? true

Position? 2

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\># Pick out the 2's from a stream



@(1,2,3) | Search-Select { param($it) $it -eq 2 }

2









-------------------------- EXAMPLE 2 --------------------------



PS C:\\># Pick out the 2's from a list



Search-Select { param($it) $it -eq 2 } -InputObject @(1,2,3)

2











RELATED LINKS