How to pass arguments to function referenced by variable
The problem is when you do
$foo = foo
You put the result of the function in the variable $foo, not the function itself !
Try this :
$foo = get-content Function:\foo
And call it like this
& $foo 5
Hope it helps !
Use a script block.
# f.ps1$foo = { param($value) $value + 5}function bar { param($callback) & $callback 5}bar($foo)
Running it:
> ./f.ps110
EDIT Misread the question the first time
What you need to do is use the & operator
& $foo 5