title: Handling pipeline and parameter input in a Powershell function
body: <p>I'm confused about something I saw in the book Learn PowerShell in a Month of lunches.  In chapter 21 when the author discusses functions that accept input via parameter binding or the pipeline he gives two patterns.</p>
  
  <p>The first as follows</p>
  
  <pre><code>function someworkerfunction {
  # do some work
  }
  function Get-SomeWork {
     param ([string[]]$computername)
     BEGIN {
        $usedParameter = $False
        if($PSBoundParameters.ContainsKey('computername')) {
           $usedParameter = $True
        }   
     }
     PROCESS {
        if($usedParameter) {
           foreach($computer in $computername) {
              someworkerfunction -computername $comptuer
           }
        } else {
           someworkerfunction -comptuername $_
        }
     }
  
     END {}
  }
  </code></pre>
  
  <p>The second like this</p>
  
  <pre><code>function someworkerfunction {
  # do stuff
  }
  function Get-Work {
     [CmdletBinding()]
     param(
        [Parameter(Mandatory=$True,
        ValueFromPipelineByPropertyName=$True)]
        [Alias('host')]
        [string[]]$computername
     )
     BEGIN {}
     PROCESS {
        foreach($computer in $computername) {
           someworkerfunction -comptuername $computer
        }
     }
     END {}
  }
  </code></pre>
  
  <p>I know the second sample is a standard Powershell 2.0 Advanced function.  My question is with Powershell 2.0 support for the cmdletbinding directive would you ever want to use the first pattern.  Is that just a legacy from Powershell 1.0?  Basically is there ever a time when using Powershell 2.0 that I would want to mess around with the first pattern, when the second pattern is so much cleaner.</p>
  
  <p>Any insight would be appreciated.</p>
  
  <p>Thank you.</p>