Advanced Tools & Scripting with PowerShell 3.0: (05) More on Parameters

Play Advanced Tools & Scripting with PowerShell 3.0: (05) More on Parameters

The Discussion

  • User profile image
    doman

    Im confused. I thought that Process{} section gets serialized data from the pipeline. So why use foreach()? As i see it now, Process section should run many times and each time foreach() loop is go over whole array again. Which would be bad. But it doesnt work that (bad) way. Why?

  • User profile image
    doman

    Oh i think i figured out why. Because in 1SimpleTemp.ps1 the $x parameter is single one, not an array. So for multiple objects coming from pipeline as input, Process{} is running multiple times. But if your parameter is already array then multiple objects from pipeline are written/gathered to that one parameter. So Process{} is called against ONE parameter. Please someone correct me if im wrong.

Add Your 2 Cents