Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
81 lines (56 loc) · 1.88 KB

File metadata and controls

81 lines (56 loc) · 1.88 KB
Copy raw file
Download raw file
Outline
Edit and raw actions

WhereEx

SYNOPSIS

POC for a simplified Where-Object with multiple conditions on the same property for PowerShell.

Script file

Extend Builtin\WhereEx.ps1

Related blog post

https://powershellone.wordpress.com/2015/11/02/simplified-where-object-for-multiple-conditions-on-the-same-property-for-powershell/

SYNTAX

WhereEx [-InputObject <Object>] [-PredicateString] <Object>

DESCRIPTION

Allows for avoiding multiple mentions of the property name when using Where-Object with multiple conditions on the same property. Parentheses indicate that the preceding variable should be considered as the (left-hand) parameter for the operator. (see Example)

EXAMPLES

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

1..10 | WhereEx {$_ (-gt 5 -and -lt 8)}

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

Get-Process | WhereEx {$_.Name (-like 'power*' -and -notlike '*ise')}

PARAMETERS

-InputObject

The object or collection to filter.

Type: Object
Parameter Sets: (All)
Aliases: 

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-PredicateString

The predicate as a String that determines the filter logic. Parentheses indicate that the preceding variable should be considered as the (left-hand) parameter for the operator.

  (See Example)
Type: Object
Parameter Sets: (All)
Aliases: 

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

INPUTS

OUTPUTS

NOTES

RELATED LINKS

https://powershellone.wordpress.com/2015/11/02/simplified-where-object-for-multiple-conditions-on-the-same-property-for-powershell/

Morty Proxy This is a proxified and sanitized view of the page, visit original site.