Difference between where-object and select-object

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.

Geplaatst in Citrix Xenapp, Powershell, Scripting.