title: How to pipeline the output of one function to another function in powershell?
body: <p>I am trying to set a new guid for my wix project . I would like to acheive this by using pipelined functions.</p>
  
  <p>I have written the following functions</p>
  
  <pre><code>Function GetGUIDFrom-Wix {
  
      [CmdletBinding()]
      [OutputType([string])]
      Param
      (
          # Param1 help description
          [Parameter(Mandatory=$true,
                     ValueFromPipelineByPropertyName=$true,
                     Position=0)]
          [ValidateScript({Test-Path $_ })]
          [string] $Path
  
  
      )
  
      Begin
      {
          $xmldata = New-Object XML
  
          $xmldata.Load($Path)
      }
      Process
      {
          $Guid = $xmldata.Wix.Product.Id
      }
      End { Write-Output $Guid }
  
  }
  
  Function SetGUIDTo-Wix {
  
      [CmdletBinding()]
      [OutputType([string])]
      Param (
           [Parameter(Mandatory=$true,
                     ValueFromPipelineByPropertyName=$false,                
                     Position=0)]
          [ValidateScript({Test-Path $_ })]
          [string] $Path,
          [Parameter(Mandatory=$true,
                     ValueFromPipelineByPropertyName=$true,
                     Position=1)]
          [string] $Guid
  
      )
  
      Begin
      {
          $xmldata = New-Object XML
  
          $xmldata.Load($Path)
      }
      Process
      {
          If ($Guid -eq  $xmldata.Wix.Product.Id ) {
  
  
  
              $NewGuid = [string] $NewGuid = [string] [guid]::newguid().tostring().toUpper()
  
              $xmldata.Wix.Product.Id = $NewGuid
  
          }
          Else { 
              Write-Error "Guid is not matching. Can't set new guid" 
          }
      }
      End {  
  
          $xmldata.Save($Path)
          return $NewGuid 
      }
  
  }
  </code></pre>
  
  <p>I thought that the funciton GetGUIDFrom-Wix will be return the guid to pipeline and SetGUIDTo-Wix will receive pipelined guid and set it in file. </p>
  
  <p>Following is my function call</p>
  
  <pre><code>$Path = E:\MyWixproj.wxs
  GetGuidFrom-Wix -Path $Path | SetGuidTo-Wix -Path $Path -guid $_
  </code></pre>
  
  <p>But the result says</p>
  
  <blockquote>
    <p>SetGUIDTo-Wix : Cannot bind argument to parameter 'Guid' because it is
    an empty string.</p>
  </blockquote>
  
  <p>If i simply execute GetGUIDFrom-Wix -Path $Path | Out-File c:\test.txt ,it returns the GUID value to the file. Can't we send the output as pipeline to another custom function?</p>