title: Does ForEach-Object operate on a single object in the pipeline or on a collection of objects?
body: <p>I've had trouble grasping how the PowerShell pipeline works and I realise a lot of the problem is due to <code>ForEach-Object</code>.  In other languages I've used, foreach operates on a collection, iterating through each element of the collection in turn.  I assumed <code>ForEach-Object</code>, when used in a PowerShell pipeline, would do the same.  However, everything I read about the pipeline suggests each element of a collection is passed through the pipeline separately and that downstream cmdlets are called repeatedly, operating on each element separately rather than on the collection as a whole.  </p>
  
  <p>So does <code>ForEach-Object</code> operate on a single element in the collection, rather than on the collection as a whole?  Looking at it a different way, does the pipeline operator pass through the whole collection to <code>ForEach-Object</code>, which then iterates over it, or does the pipeline object iterate over the collection and pass each element separately to <code>ForEach-Object</code>?</p>