It is more convenient than the previous version using Where-object.
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