1
Vote

Embedding $finalizeProxyCommandScript in a ScriptBlock causes $PSCmdlet to fail.

description

In the following section of New-ProxyFunction $finalizeProxyCommandScript is embedded in a ScriptBlock and that causes $PSCmdlet.MyInvocation.MyCommand to fail.
$finalizeProxyCommand = @"


            #region Finalize the proxy command.

            & {
$finalizeProxyCommandScript
            }

            #endregion

"@
If you remove the ScriptBlock as follows, it works correctly:
$finalizeProxyCommand = @"


            #region Finalize the proxy command.

$finalizeProxyCommandScript

            #endregion

"@

comments