Difference between where-object and select-object

Difference between where-object and select-object

Q. What is the difference between where-object and select-object?

A. The two cmdlets perform very different things.

Where-object restricts which objects are returned, for example:

Get-Process | Where-Object {$_.Name -eq "WmiPrvSE"}

Will only return objects whose name is WmiPrvSE.

Now compare to Select-Object, e.g.

Get-Process | Select-Object -Property Name, ID

Returns the name and process ID for every process. You could put these together:

Get-Process | Where-Object {$_.Name -eq "WmiPrvSE"} | Select-Object -Property Name, ID

To return only the Name and ID for the WmiPrvSE process instances.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.