Bez kategorii

[Powershell] Simplified „where” syntax

get-proces
Today I want show You simplified „Where-Object” syntax in 3.0 version of Powershell. In 2.0 version We could use „where” or „?” for filtering results of command. Now it’s more simply.

In version 2.0 We could use „Where-Object” option for filtering results. For example:

 

Get-Process | Where-Object {$_.Name -eq "explorer"}
Get-Process | where {$_.Name -eq "explorer"}
Get-Process |? {$_.Name -eq "explorer"}

All 3 command give the same results.

Now It’s more easy to use:)

Get-Process |? name -eq "explorer"

Best Regards 🙂