Take the 2-minute tour ×  In experimenting with scriptblocks, I
was attempting to use a scriptblock parameter with an advanced
function and noticed that it performs differently than when
supplied to a compiled cmdlet.  In reviewing this blog post from
the PowerShell Team blog, it appears that the PowerShell engine
should be evaluating the scriptblock if a scriptblock is not a
valid input for the parameter. It seems that when calling the
function with a scriptblock parameter, it attempts to convert a
scriptblock to the parameters type directly, rather than
evaluating the scriptblock based on the current object in the
pipeline.  My intention is to duplicate behavior like:  Import-
CSV somecsv.csv | get-wmiobject -class {$_.class} -Computer
{$_.computer}  for advanced functions.  Example script:  $sb =
{throw "If there was an error, the scriptblock was evaluated!"}
function test ()   param (
[Parameter(ValueFromPipelineByPropertyName = $true)]    write-
host $Fullname, $ThisShouldBeEvaluatedForEachItem Get-Ch