Passing function names

Richard Siddaway
1 min read
Share:

A question asked about passing a function name into another function which then called the function. It sounds worse than it is. if you need to pass the name of a command and then call it try using invoke-expression

`function

ffour

{

Get-Random

}

function

fthree

{

Get-Date

}

function

ftwo

{

param

(

[string]

$fname

)

Invoke-Expression

$fname

}

“date”

ftwo

fthree

“random”

ftwo

ffour

`