Tag Archives: where

Easier ForEach/Where-Object in Powershell V3

PowerTip of the Day, from PowerShell.com

In the upcoming PowerShell v3 which you can already download as a Beta version, using Where-Object and ForEach-Object becomes a lot simpler. No longer do you need a script block and code. This, for example, is all you need to find files larger than 1MB:

Get-ChildItem $env:windir | Where-Object Length -gt 1MB

Previously, you would have had to write:

Get-ChildItem $env:windir | Where-Object { $_.Length -gt 1MB }