Invoking Function in PowerShell via String Invoking Function in PowerShell via String powershell powershell

Invoking Function in PowerShell via String


You can do this:

 &"MyFunctionName" $arg1 $arg2


If you're wanting to variableize the whlole thing:

function myfunctionname {write-host "$($args[0]) $($args[1])"}$arg1 = "scripts"$arg2 = "test"$functionToInvoke = "MyFunctionName";invoke-expression  "$functionToInvoke $arg1 $arg2"scripts test