title: Passing properties to a function pipeline output error
body: <p>I'm getting this error when I add to the return the <code>-prefix "File_Name"</code> to the end of <code>Return $Results | Out-Excel -Prefix "File_Name"</code> if I leave <code>-prefix "File_Name"</code> off of the script it works. What am I missing?</p>
  
  <pre><code>Out-Excel : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of 
  the parameters that take pipeline input.
  At \\util01\cs\Scripts\PowerShell\BradleyDev\Google Chrome\Set-Chrome-Service-ON-V3.ps1:52 char:21
  + } Return $Results | Out-Excel -Prefix "File_Name"
  +                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidArgument: (@{PC=CD-100TRAINER; Status=OFF-LINE}:PSObject) [Out-Excel], ParameterBindingException
      + FullyQualifiedErrorId : InputObjectNotBound,Out-Excel
  </code></pre>
  
  <hr>
  
  <pre><code>foreach ($PC in $Process){
  $counter ++
  $Service = "gupdate"
  $State = "delayed-auto"
  $command = "sc.exe \\$PC config $Service start= $State"
  $count = $Process.Count
  $command2 = "sc.exe \\$PC config gupdatem start= demand"
  if (test-connection -computername $PC -BufferSize 16 -Count 1 -quiet) {
      $Output = Invoke-Expression -Command $Command -ErrorAction Stop
      $Output = Invoke-Expression -Command $Command2 -ErrorAction Stop
      if($LASTEXITCODE -ne 0){
         Write-Host "$counter of $count : $PC : Failed More details: $Output" -foregroundcolor White -BackgroundColor RED
         $status = [string]$Output
      } else {
         Write-Host "$counter of $count : $PC : Success" -foregroundcolor DarkGreen
         $status = "Success"
      }
  } else {
      Write-Host "$counter of $count : $PC : OFF-LINE" -foregroundcolor black -BackgroundColor gray
      $status = "OFF-LINE"
  }       
  $PCobject = [PSCustomObject] @{
      PC = $PC
      Status = $status
  }
  $Results +=$PCobject
  } Return $Results | Out-Excel -Prefix "File_Name"
  </code></pre>
  
  <hr>
  
  <pre><code>function Out-Excel {
  param(
      [Parameter(Mandatory=$True,HelpMessage="Enter Prefix",ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
      [ValidateNotNullorEmpty()]
      [string[]]$Prefix = $null,
      $Path = "$env:temp\$Prefix`_$(Get-Date -Format yyMMdd_HHmmss).csv"
  )
  $input | Export-CSV -Path $Path -UseCulture -Encoding UTF8 -NoTypeInformation
  Invoke-Item -Path $Path
  } #end function
  </code></pre>
  
  <p>Updated but still failing:</p>
  
  <pre><code>function Out-Excel {
      param(
          [Parameter(Mandatory=$True,HelpMessage="Enter Prefix")]
          [ValidateNotNullorEmpty()]
          [string[]]$Prefix = $null,
          $Path = "$env:temp\$Prefix`_$(Get-Date -Format yyMMdd_HHmmss).csv"
      )
      $input | Export-CSV -Path $Path -UseCulture -Encoding UTF8 -NoTypeInformation
      Invoke-Item -Path $Path
  } #end function
  </code></pre>
  
  <p>ERROR:</p>
  
  <pre><code>Out-Excel : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and 
  its properties do not match any of the parameters that take pipeline input.
  At \\util01\cs\Scripts\PowerShell\BradleyDev\Google Chrome\Set-Chrome-Service-ON-V3.ps1:52 char:14
  + } $Results | Out-Excel -Prefix "Services_Results"
  +              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidArgument: (@{PC=CD-100TRAINER; Status=OFF-LINE}:PSObject) [Out-Excel], ParameterBindingException
      + FullyQualifiedErrorId : InputObjectNotBound,Out-Excel
  </code></pre>
  
  <hr>
  
  <h2>This works:</h2>
  
  <p>I wanted to be able to use the function and set a file name prefix depending on name of the results. The code below works by adding another parameter "the object" I want to pass to the function, <strong>however I loose the ability to pipe the object to the function</strong>. Apparently if I use $input I can not take pipeline arguments?</p>
  
  <pre><code>function Out-Excel {
  param(
      [Parameter(Mandatory=$True,HelpMessage="Enter Prefix")]
      [ValidateNotNullorEmpty()]
      [string[]]$Prefix = $null,
      [Parameter(Mandatory=$True,HelpMessage="Enter Prefix")]
      [ValidateNotNullorEmpty()]
      [object]$Object = $null,
      $Path = "$env:temp\$Prefix`_$(Get-Date -Format yyMMdd_HHmmss).csv"
  )
  $Object | Export-CSV -Path $Path -UseCulture -Encoding UTF8 -NoTypeInformation
  Invoke-Item -Path $Path
  } #end function
  </code></pre>
  
  <hr>
  
  <pre><code>$Results +=$PCobject
   } Out-Excel -object $Results -Prefix "Services_Results"`
  </code></pre>