Creates a filter that controls which objects will be passed along a command pipeline. (Where-Object)

   

# NAME
Where-Object

# SYNOPSIS
Creates a filter that controls which objects will be passed along a command pipeline.

# SYNTAX
Where-Object [-FilterScript] <scriptblock> [-InputObject <psobject>] [<CommonParameters>]

# DESCRIPTION
The Where-Object cmdlet selects objects from the set of objects that are passed to it. It uses a script block as a filter and evaluates the script block for each object. If the result of the evaluation is True, the object is returned. If the result of the evaluation is not True, the object is ignored.

# PARAMETERS
-FilterScript <scriptblock>
Specifies the script block that is used to filter the objects. Enclose the script block in braces ( {} ).

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

-InputObject <psobject>
Specifies the objects to be filtered. You can also pipe the objects to Where-Object.

Required? false
Position? named
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 and OutVariable. For more information, type,
"get-help about_commonparameters".

# INPUTS
System.Management.Automation.PSObject
You can pipe the objects to be filtered to Where-Object.

# OUTPUTS

# NOTES

# EXAMPLE 1

C:\PS>get-service | where-object {$_.Status -eq "Stopped"}

# Description
-----------
This command gets a list of all services that are currently stopped. The "$" symbol represents each object that is passed to the Where-Object cmdlet.

# EXAMPLE 2

C:\PS>get-process | where-object {$_.workingset -gt 25000*1024}

# Description
-----------
This command lists 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.

# EXAMPLE 3

C:\PS>get-process | where-object { $_.ProcessName -match "^p.*" }

# Description
-----------
This command gets the processes with a ProcessName property that begins with the letter "p". The match operator enables you to use regular expressions within a Where clause.

# EXAMPLE 4

C:\PS>get-process -name svchost | where-object {$True}

# Description
-----------
This command lists all of the processes named "svchost".

The Where-Object cmdlet evaluates the script block, which typically includes a reference to the object currently in the pipeline ($_), and casts the results to a Boolean type: True or False. If the result is True, the object is returned. Otherwise, it is discarded.

In this case, the script block just returns True, so all the objects are returned.

RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=113423

C:\Windows>powershell get-help Set-PSDebug -full

ColorConsole [Version 1.7.1000] PowerShell 2.0-Export
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2014 Microsoft Corporation.

OS: Windows 10, 8.1, 8, 7, Vista / Windows Server 2016, 2012, 2008
»»»» ColorConsole









... Windows-10




Windows 10 How To

... Windows 10 FAQ
... Windows 10 How To




PowerShell: Creates a filter that controls which objects will be passed along a command pipeline.

HTTP: ... PS_Windows/en/Where-Object.htm
0.359
14724

How to see all shared folders on Windows-10 Home and Pro?

 /

Bildschirmschoner verhindern unter Windows 10, 8.1, ...!

 /

Was sind die Vorteile und Nachteile von exFat bei Windows 10, 8.1, 7, ...?

 /

Help I lost the Windows Performance Index Tool can i use it again W10?

 /

Remove, delete and manage the libraries on Windows 7, how can I do?

 /

Environment Variables?

 /

Microsoft Onedrive and Explore Views problem affects directorys and files contained!

 /

Where can I change the Hertz on the Windows 10 laptop?

 /

The Windows 8.1 Desktop Search!

 /

Horizontal scrolling with always mouse wheel, can I?

 /

If the network drive disappears after restart or update!

 /

Click on identical photos to delete them, I will not be able to finish my work!

 /