Contact Info

Crumbtrail

ActiveXperts.com » Administration » Powershell » Powershell 1.0 » Where-Object

Where-Object - Powershell 1.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.

Where-Object

Description
Filter input from the pipeline

Usage


Options
-filterScript scriptblock
       The script block to evaluate. This will determine which input objects
       will be passed along the command pipeline.

   -inputObject psobject
        The objects to be filtered. Rarely used as typically the objects will 
        be passed to Where-Object through the pipeline.

   CommonParameters:
       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.

Example(s)
Get a list of all services that are currently stopped:

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

Lists the processes with a working set greater than 25000K. (bytes = Kilobytes*1024):

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

Get the processes with a ProcessName property that begins with the letter p. The -match operator enables you to use regular expressions:

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