It can be useful to run functions (vs. scripts) in the current scope. @Jaykul's Get-ParameterValues is an example
At the moment, it appears that a dot sourced function does not actually run in the current scope. Apologies if I'm using the wrong phrasing, the example should clarify things:
Steps to reproduce
function Test-MyInvocationParam {
[cmdletbinding()]
param($Invocation = $MyInvocation)
$Invocation
}
function Test-Bug {
[cmdletbinding()]
param($a=1)
. Test-MyInvocationParam
}
(Test-Bug).MyCommand.Name
Expected behavior
Actual behavior
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.0-beta
PSEdition Core
GitCommitId v6.0.0-beta.7
OS Darwin 16.7.0 Darwin Kernel Version 16.7.0: Th...
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
It can be useful to run functions (vs. scripts) in the current scope. @Jaykul's Get-ParameterValues is an example
At the moment, it appears that a dot sourced function does not actually run in the current scope. Apologies if I'm using the wrong phrasing, the example should clarify things:
Steps to reproduce
Expected behavior
Actual behavior
Environment data