Passing function names

Uncategorized

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

Comments are closed.