For last hours I'm trying to figure out how to pass a scriptblock to a function to be used as a filter for where object. I haven't found any documentation, I must be missing something. I saw "filter script:" and "function:script" definitions in What is the recommended coding style for PowerShell? but I have no idea how these are used and I can't find it anywhere.
function Test
{
Param(
$f,
$What
)
$x = $What | where $f
$x
}
$mywhat = @('aaa', 'b', 'abb', 'bac')
filter script:myfilter {$_ -like 'a*'}
Test -What $mywhat -xx $myfilter
Can someone please point me to the right direction?