|
|
|
|
|
by drblast
4963 days ago
|
|
I can best explain via example. Let's say I want to iterate through a directory and do something to each file: ls C:\ | foreach{echo $_.Name}
That will print out the file name. The $_ variable represents each file object that ls returns. Let's say I want the file creation times instead: ls C:\ | foreach{echo $_.CreationTime}
Or just the day of the week the file was created: ls C:\ | foreach{echo $_.CreationTime.DayOfWeek}
It's incredibly powerful. And the default is always a text representation of the object anyway, so it seems like text is getting piped, just like Unix. If you do this: ls C:\ | foreach{echo $_}
You get a typical directory listing. |
|