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 }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s