Here is an example:
function ChildF() { #Creating new function dynamically $DynFEx = @\" function DynF() { \"Hello DynF\" } \"@ Invoke-Expres
A more correct and functional way to do this would be to return the function body as a script block and then recompose it.
function ChildF() { function DynF() { "Hello DynF" } return ${function:DynF} } $DynFEx = ChildF Invoke-Expression -Command "function DynF { $DynFEx }" DynF