Created
April 4, 2011 20:58
-
-
Save emiliano-poggi/902424 to your computer and use it in GitHub Desktop.
POSH: For each constructs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# foreach statement | |
foreach ($ps1 in ls -filter $home\*.ps1) {$ps1.length/1024} | |
# foreach inside the pipeline | |
ls -filter $home\*.ps1 | ForEach-Object -process {$_.length/1024} | |
# foreach inside the pipeline omitting -process | |
ls -filter $home\*.ps1 | ForEach-Object {$_.length/1024} | |
# foreach inside the pipeline using foreach alias | |
ls -filter $home\*.ps1 | foreach {$_.length/1024} | |
# foreach inside the pipeline using % alias | |
ls -filter $home\*.ps1 | % {$_.length/1024} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment