Book Image

PowerShell Troubleshooting Guide

By : Mike Shepard
Book Image

PowerShell Troubleshooting Guide

By: Mike Shepard

Overview of this book

Table of Contents (15 chapters)
PowerShell Troubleshooting Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Pipelines and function execution


Although pipelines are written sequentially with each element following the previous one, function execution in a pipeline is somewhat different. In order to illustrate this, consider the following advanced functions that all allow pipeline input:

function A{
[CmdletBinding()]
Param([Parameter(ValueFromPipeline=$true)]$x)
  begin { Write-Host "A in begin"}
  process { Write-Host "A in Process{}"
           Write-Output $x }
  end { Write-Host "A in end"}
}
function B{
[CmdletBinding()]
Param([Parameter(ValueFromPipeline=$true)]$y)
  begin { Write-Host "B in begin"}
  process { Write-Host "B in Process{}"
           Write-Output $y }
  end { Write-Host "B in end"}
}
function C{
[CmdletBinding()]
Param([Parameter(ValueFromPipeline=$true)]$z)
  begin { Write-Host "C in begin"}
  process { Write-Host "C in Process{}"
           Write-Output $z }
  end { Write-Host "C in end"}
}

The only thing these functions do is display a message when one of the three Begin-Process...