例如: function Foo { [string]$functionName = commandRetrievesFoo Write-Host "This function is called $functionName"} 输出: PS FooThis function is called foo 您可以使用$MyInvocation,其中包含有关当前执行的内容的一些
function Foo { [string]$functionName = commandRetrievesFoo Write-Host "This function is called $functionName" }
输出:
PS > Foo This function is called foo您可以使用$MyInvocation,其中包含有关当前执行的内容的一些有用信息.
function foo { 'This function is called {0}.' -f $MyInvocation.MyCommand }