NAME

select-first

SYNOPSIS

Identifies the first element in the pipeline that meets the specified criteria.

SYNTAX

select-first [[-InputObject] <Object>] [[-predicate] <ScriptBlock>] [<CommonParameters>]

DESCRIPTION

Processes each input item until the script block specified in the predicate parameter has been satisfied.

Once the predicate returns a true value, the elements are discarded and the script block is no longer invoked.

PARAMETERS

-InputObject <Object>

Required? false
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters?


-predicate <ScriptBlock>
the conditional to apply to each input element; defaults to {$_}

Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters?


<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS

System.Object[]. A collection of objects.

OUTPUTS

System.Object. The first object that meets the criteria specified in the predicate script block.

EXAMPLES

EXAMPLE 1

C:\PS>$c = 'this is the only value' 
C:\PS> @($a,$b,$c,$d) | select-first

'this is the only value'

EXAMPLE 2

C:\PS>@(1,2,3,4,5) | select-first { $_ -gt 3 }
    
4

Last edited Dec 30, 2011 at 3:47 AM by beefarino, version 1

Comments

No comments yet.