Where-Object
Selects objects from a collection based on their property values.
语法
EqualSet (默认值)
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-EQ]
[<CommonParameters>]
ScriptBlockSet
Where-Object
[-FilterScript] <ScriptBlock>
[-InputObject <PSObject>]
[<CommonParameters>]
LessOrEqualSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-LE]
[<CommonParameters>]
CaseSensitiveGreaterOrEqualSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-CGE]
[<CommonParameters>]
CaseSensitiveLessOrEqualSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-CLE]
[<CommonParameters>]
CaseSensitiveInSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-CIn]
[<CommonParameters>]
GreaterOrEqualSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-GE]
[<CommonParameters>]
CaseSensitiveLikeSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-CLike]
[<CommonParameters>]
NotLikeSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-NotLike]
[<CommonParameters>]
CaseSensitiveNotLikeSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-CNotLike]
[<CommonParameters>]
MatchSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-Match]
[<CommonParameters>]
CaseSensitiveMatchSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-CMatch]
[<CommonParameters>]
NotMatchSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-NotMatch]
[<CommonParameters>]
CaseSensitiveNotMatchSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-CNotMatch]
[<CommonParameters>]
ContainsSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-Contains]
[<CommonParameters>]
CaseSensitiveContainsSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-CContains]
[<CommonParameters>]
NotContainsSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-NotContains]
[<CommonParameters>]
CaseSensitiveNotContainsSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-CNotContains]
[<CommonParameters>]
InSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-In]
[<CommonParameters>]
LikeSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-Like]
[<CommonParameters>]
NotInSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-NotIn]
[<CommonParameters>]
CaseSensitiveNotInSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-CNotIn]
[<CommonParameters>]
IsSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-Is]
[<CommonParameters>]
IsNotSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-IsNot]
[<CommonParameters>]
CaseSensitiveEqualSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-CEQ]
[<CommonParameters>]
NotEqualSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-NE]
[<CommonParameters>]
CaseSensitiveNotEqualSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-CNE]
[<CommonParameters>]
GreaterThanSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-GT]
[<CommonParameters>]
CaseSensitiveGreaterThanSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-CGT]
[<CommonParameters>]
LessThanSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-LT]
[<CommonParameters>]
CaseSensitiveLessThanSet
Where-Object
[-Property] <String>
[[-Value] <Object>]
[-InputObject <PSObject>]
[-CLT]
[<CommonParameters>]
说明
The Where-Object
cmdlet selects objects that have particular property values from the collection of objects that are passed to it.
For example, you can use the Where-Object
cmdlet to select files that were created after a certain date, events with a particular ID, or computers that use a particular version of Windows.
Starting in Windows PowerShell 3.0, there are two different ways to construct a Where-Object
command.
Script block. You can use a script block to specify the property name, a comparison operator, and a property value.
Where-Object
returns all objects for which the script block statement is true.For example, the following command gets processes in the Normal priority class, that is, processes where the value of the PriorityClass property equals Normal.
Get-Process | Where-Object {$_.PriorityClass -eq "Normal"}
All PowerShell comparison operators are valid in the script block format. For more information about comparison operators, see about_Comparison_Operators.
Comparison statement. You can also write a comparison statement, which is much more like natural language. Comparison statements were introduced in Windows PowerShell 3.0.
For example, the following commands also get processes that have a priority class of Normal. These commands are equivalent and can be used interchangeably.
Get-Process | Where-Object -Property PriorityClass -eq -Value "Normal"
Get-Process | Where-Object PriorityClass -eq "Normal"
Starting in Windows PowerShell 3.0, Where-Object adds comparison operators as parameters in a Where-Object command. Unless specified, all operators are case-insensitive. Prior to Windows PowerShell 3.0, the comparison operators in the PowerShell language could be used only in script blocks.
示例
Example 1: Get stopped services
These commands get a list of all services that are currently stopped.
The $_
automatic variable represents each object that is passed to the Where-Object
cmdlet.
The first command uses the script block format, the second command uses the comparison statement format.
The commands are equivalent and can be used interchangeably.
Get-Service | Where-Object {$_.Status -eq "Stopped"}
Get-Service | where Status -eq "Stopped"
Example 2: Get processes based on working set
These commands list processes that have a working set greater than 25,000 kilobytes (KB). Because the value of the WorkingSet property is stored in bytes, the value of 25,000 is multiplied by 1,024.
The scriptblock and statement syntax are equivalent and can be used interchangeably.
Get-Process | Where-Object {$_.WorkingSet -GT 25000*1024}
Get-Process | Where-Object WorkingSet -GT (25000*1024)
Example 3: Get processes based on process name
These commands get the processes that have a ProcessName property value that begins with the letter p. The Match operator lets you use regular expression matches.
The scriptblock and statement syntax are equivalent and can be used interchangeably.
Get-Process | Where-Object {$_.ProcessName -Match "^p.*"}
Get-Process | Where-Object ProcessName -Match "^p.*"
Example 4: Use the comparison statement format
This example shows how to use the new comparison statement format of the Where-Object
cmdlet.
The first command uses the comparison statement format. In this command, no aliases are used and all parameters include the parameter name.
The second command is the more natural use of the comparison command format.
The where alias is substituted for the Where-Object
cmdlet name and all optional parameter names are omitted.
Get-Process | Where-Object -Property Handles -GE -Value 1000
Get-Process | where Handles -GE 1000
Example 5: Get commands based on properties
This example shows how to write commands that return items that are true or false or have any value for a specified property. Each example shows both the script block and comparison statement formats for the command.
# Use Where-Object to get commands that have any value for the OutputType property of the command.
# This omits commands that do not have an OutputType property and those that have an OutputType property, but no property value.
Get-Command | where OutputType
Get-Command | where {$_.OutputType}
# Use Where-Object to get objects that are containers.
# This gets objects that have the **PSIsContainer** property with a value of $True and excludes all others.
Get-ChildItem | where PSIsContainer
Get-ChildItem | where {$_.PSIsContainer}
# Finally, use the Not operator (!) to get objects that are not containers.
# This gets objects that do have the **PSIsContainer** property and those that have a value of $False for the **PSIsContainer** property.
Get-ChildItem | where {!$_.PSIsContainer}
# You cannot use the Not operator (!) in the comparison statement format of the command.
Get-ChildItem | where PSIsContainer -eq $False
Example 6: Use multiple conditions
Get-Module -ListAvailable | where {($_.Name -notlike "Microsoft*" -and $_.Name -notlike "PS*") -and $_.HelpInfoUri}
This example shows how to create a Where-Object
command with multiple conditions.
This command gets non-core modules that support the Updatable Help feature.
The command uses the ListAvailable parameter of the Get-Module
cmdlet to get all modules on the computer.
A pipeline operator (|) sends the modules to the Where-Object
cmdlet, which gets modules whose names do not begin with Microsoft or PS, and have a value for the HelpInfoURI property, which tells PowerShell where to find updated help files for the module.
The comparison statements are connected by the And logical operator.
The example uses the script block command format.
Logical operators, such as And and Or, are valid only in script blocks.
You cannot use them in the comparison statement format of a Where-Object
command.
- For more information about PowerShell logical operators, see about_Logical_Operators.
- For more information about the Updatable Help feature, see about_Updatable_Help.
参数
-CContains
Indicates that this cmdlet gets objects from a collection if the property value of the object is an exact match for the specified value. This operation is case-sensitive.
For example: Get-Process | where ProcessName -CContains "svchost"
CContains refers to a collection of values and is true if the collection contains an item that is an exact match for the specified value. If the input is a single object, PowerShell converts it to a collection of one object.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
CaseSensitiveContainsSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-CEQ
Indicates that this cmdlet gets objects if the property value is the same as the specified value. This operation is case-sensitive.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
CaseSensitiveEqualSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-CGE
Indicates that this cmdlet gets objects if the property value is greater than or equal to the specified value. This operation is case-sensitive.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
CaseSensitiveGreaterOrEqualSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-CGT
Indicates that this cmdlet gets objects if the property value is greater than the specified value. This operation is case-sensitive.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
CaseSensitiveGreaterThanSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-CIn
Indicates that this cmdlet gets objects if the property value includes the specified value. This operation is case-sensitive.
For example: Get-Process | where -Value "svchost" -CIn ProcessName
CIn resembles CContains, except that the property and value positions are reversed. For example, the following statements are both true.
"abc", "def" -CContains "abc"
"abc" -CIn "abc", "def"
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
CaseSensitiveInSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-CLE
Indicates that this cmdlet gets objects if the property value is less-than or equal to the specified value. This operation is case-sensitive.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
CaseSensitiveLessOrEqualSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-CLike
Indicates that this cmdlet gets objects if the property value matches a value that includes wildcard characters. This operation is case-sensitive.
For example: Get-Process | where ProcessName -CLike "*host"
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
CaseSensitiveLikeSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-CLT
Indicates that this cmdlet gets objects if the property value is less-than the specified value. This operation is case-sensitive.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
CaseSensitiveLessThanSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-CMatch
Indicates that this cmdlet gets objects if the property value matches the specified regular expression.
This operation is case-sensitive.
When the input is scalar, the matched value is saved in $Matches
automatic variable.
For example: Get-Process | where ProcessName -CMatch "Shell"
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
CaseSensitiveMatchSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-CNE
Indicates that this cmdlet gets objects if the property value is different than the specified value. This operation is case-sensitive.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
CaseSensitiveNotEqualSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-CNotContains
Indicates that this cmdlet gets objects if the property value of the object is not an exact match for the specified value. This operation is case-sensitive.
For example: Get-Process | where ProcessName -CNotContains "svchost"
"NotContains" and "CNotContains refer to a collection of values and are true when the collection does not contains any items that are an exact match for the specified value. If the input is a single object, PowerShell converts it to a collection of one object.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
CaseSensitiveNotContainsSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-CNotIn
Indicates that this cmdlet gets objects if the property value is not an exact match for the specified value. This operation is case-sensitive.
For example: Get-Process | where -Value "svchost" -CNotIn -Property ProcessName
NotIn and CNotIn operators resemble NotContains and CNotContains, except that the property and value positions are reversed. For example, the following statements are true.
"abc", "def" -CNotContains "Abc"
"abc" -CNotIn "Abc", "def"
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
CaseSensitiveNotInSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-CNotLike
Indicates that this cmdlet gets objects if the property value does not match a value that includes wildcard characters. This operation is case-sensitive.
For example: Get-Process | where ProcessName -CNotLike "*host"
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
CaseSensitiveNotLikeSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-CNotMatch
Indicates that this cmdlet gets objects if the property value does not match the specified regular expression.
This operation is case-sensitive.
When the input is scalar, the matched value is saved in $Matches
automatic variable.
For example: Get-Process | where ProcessName -CNotMatch "Shell"
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
CaseSensitiveNotMatchSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Contains
Indicates that this cmdlet gets objects if any item in the property value of the object is an exact match for the specified value.
For example: Get-Process | where ProcessName -Contains "Svchost"
If the property value contains a single object, PowerShell converts it to a collection of one object.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | IContains |
参数集
ContainsSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-EQ
Indicates that this cmdlet gets objects if the property value is the same as the specified value.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | IEQ |
参数集
EqualSet
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-FilterScript
Specifies the script block that is used to filter the objects. Enclose the script block in braces ( {} ).
The parameter name, FilterScript, is optional.
参数属性
类型: | ScriptBlock |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
ScriptBlockSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-GE
Indicates that this cmdlet gets objects if the property value is greater than or equal to the specified value.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | IGE |
参数集
GreaterOrEqualSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-GT
Indicates that this cmdlet gets objects if the property value is greater than the specified value.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | IGT |
参数集
GreaterThanSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-In
Indicates that this cmdlet gets objects if the property value matches any of the specified values.
For example: Get-Process | where -Property ProcessName -in -Value "Svchost", "TaskHost", "WsmProvHost"
If the value of the Value parameter is a single object, PowerShell converts it to a collection of one object.
If the property value of an object is an array, PowerShell uses reference equality to determine a match.
Where-Object
returns the object only if the value of the Property parameter and any value of Value are the same instance of an object.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | IIn |
参数集
InSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-InputObject
Specifies the objects to be filtered.
You can also pipe the objects to Where-Object
.
When you use the InputObject parameter with Where-Object
, instead of piping command results to Where-Object
, the InputObject value is treated as a single object.
This is true even if the value is a collection that is the result of a command, such as -InputObject (Get-Process)
.
Because InputObject cannot return individual properties from an array or collection of objects, we recommend that, if you use Where-Object
to filter a collection of objects for those objects that have specific values in defined properties, you use Where-Object
in the pipeline, as shown in the examples in this topic.
参数属性
类型: | PSObject |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | True |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Is
Indicates that this cmdlet gets objects if the property value is an instance of the specified .NET Framework type. Enclose the type name in square brackets.
For example, Get-Process | where StartTime -Is [DateTime]
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
IsSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-IsNot
Indicates that this cmdlet gets objects if the property value is not an instance of the specified .NET Framework type.
For example, Get-Process | where StartTime -IsNot [DateTime]
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
IsNotSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-LE
Indicates that this cmdlet gets objects if the property value is less than or equal to the specified value.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | ILE |
参数集
LessOrEqualSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Like
Indicates that this cmdlet gets objects if the property value matches a value that includes wildcard characters.
For example: Get-Process | where ProcessName -Like "*host"
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | ILike |
参数集
LikeSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-LT
Indicates that this cmdlet gets objects if the property value is less than the specified value.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | ILT |
参数集
LessThanSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Match
Indicates that this cmdlet gets objects if the property value matches the specified regular expression.
When the input is scalar, the matched value is saved in $Matches
automatic variable.
For example: Get-Process | where ProcessName -Match "shell"
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | IMatch |
参数集
MatchSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-NE
Indicates that this cmdlet gets objects if the property value is different than the specified value.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | INE |
参数集
NotEqualSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-NotContains
Indicates that this cmdlet gets objects if none of the items in the property value is an exact match for the specified value.
For example: Get-Process | where ProcessName -NotContains "Svchost"
NotContains refers to a collection of values and is true if the collection does not contain any items that are an exact match for the specified value. If the input is a single object, PowerShell converts it to a collection of one object.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | INotContains |
参数集
NotContainsSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-NotIn
Indicates that this cmdlet gets objects if the property value is not an exact match for any of the specified values.
For example: Get-Process | where -Value "svchost" -NotIn -Property ProcessName
If the value of Value is a single object, PowerShell converts it to a collection of one object.
If the property value of an object is an array, PowerShell uses reference equality to determine a match.
Where-Object
returns the object only if the value of Property and any value of Value are not the same instance of an object.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | INotIn |
参数集
NotInSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-NotLike
Indicates that this cmdlet gets objects if the property value does not match a value that includes wildcard characters.
For example: Get-Process | where ProcessName -NotLike "*host"
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | INotLike |
参数集
NotLikeSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-NotMatch
Indicates that this cmdlet gets objects when the property value does not match the specified regular expression.
When the input is scalar, the matched value is saved in $Matches
automatic variable.
For example: Get-Process | where ProcessName -NotMatch "PowerShell"
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | SwitchParameter |
默认值: | None |
支持通配符: | False |
不显示: | False |
别名: | INotMatch |
参数集
NotMatchSet
Position: | Named |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Property
Specifies the name of an object property.
The parameter name, Property, is optional.
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
EqualSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
LessOrEqualSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveGreaterOrEqualSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveLessOrEqualSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveInSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
GreaterOrEqualSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveLikeSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
NotLikeSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveNotLikeSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
MatchSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveMatchSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
NotMatchSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveNotMatchSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
ContainsSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveContainsSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
NotContainsSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveNotContainsSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
InSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
LikeSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
NotInSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveNotInSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
IsSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
IsNotSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveEqualSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
NotEqualSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveNotEqualSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
GreaterThanSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveGreaterThanSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
LessThanSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveLessThanSet
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-Value
Specifies a property value. The parameter name, Value, is optional. This parameter accepts wildcard characters when used with the following comparison parameters:
- CLike
- CNotLike
- Like
- NotLike
This parameter was introduced in Windows PowerShell 3.0.
参数属性
类型: | Object |
默认值: | None |
支持通配符: | True |
不显示: | False |
参数集
EqualSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
LessOrEqualSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveGreaterOrEqualSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveLessOrEqualSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveInSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
GreaterOrEqualSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveLikeSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
NotLikeSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveNotLikeSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
MatchSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveMatchSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
NotMatchSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveNotMatchSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
ContainsSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveContainsSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
NotContainsSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveNotContainsSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
InSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
LikeSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
NotInSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveNotInSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
IsSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
IsNotSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveEqualSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
NotEqualSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveNotEqualSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
GreaterThanSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveGreaterThanSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
LessThanSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CaseSensitiveLessThanSet
Position: | 1 |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
输入
PSObject
You can pipe the objects to this cmdlet.
输出
Object
This cmdlet returns selected items from the input object set.
备注
- Starting in Windows PowerShell 4.0,
Where
andForEach
methods were added for use with collections.- You can read more about these new methods here about_arrays