It is more convenient than the previous version using Where-object.

Unlock-PowerShell

I was perusing the samples that come with the PowerShell V3  CTP (Samples\WindowsPowerShell) when I noticed a folder called “Simplified Foreach and Where”

Lo and behold, you no longer need curly braces “{}” or the $_ to refer to the current object in the ForEach-Object and  Where-Object cmdlets!

The sample is incredibly simple, but quickly shows the power of this new feature:

001
002
003
004
005
006
007
008
009
010
# Suggestion: Simplified Where and Foreach
# This is the same demo that we showed during the Summit Preview live meeting
# We just like it so much that we want to show it again
# You no longer need {} and $_ to do Where-Object
Get-Process | where Name -eq powershell
# Same thing with Foreach-Object
notepad;notepad;notepad;
Get-Process | where name -eq 

View original post 29 more words

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s