Is there a way to retrieve a function name from within a function.
for example:
function foo { [string]$functionName = commnandRetrievesFoo Write-Host "This function is called $functionName" }
PS > This function is called foo
Is there a way to retrieve a function name from within a function.
for example:
function foo { [string]$functionName = commnandRetrievesFoo Write-Host "This function is called $functionName" }
PS > This function is called foo
You can use $MyInvocation
which contains some useful information about what is currently executed.
function foo {
'This function is called {0}.' -f $MyInvocation.MyCommand
}