Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Foreach loop

$
0
0

I’m not sure where that “avoid the pipeline” sound byte came from originally, but it’s been taken way out of context. It’s important to know when to use the pipeline (essentially, anytime streaming of objects is required.) That said, if you already have a whole collection in memory to begin with, the foreach statement gives much better performance.

The pipeline is the only way to process items output by a cmdlet one at a time, but it doesn’t necessarily mean you’re using ForEach-Object. Any command that accepts pipeline input can be used, including your own functions or filters.


Viewing all articles
Browse latest Browse all 13067

Trending Articles