Skip to content

Latest commit

 

History

History
36 lines (24 loc) · 1.78 KB

File metadata and controls

36 lines (24 loc) · 1.78 KB

Script block scope

If a script block is passed in a script function and invoked there by the dot operator then it operates in the current scope.

If a script block is passed in a module function and invoked there by the dot operator then it does not operate in the current scope. Where it operates depends on other factors.

Scripts

Workaround

A workaround was suggested by Tom Maddock at Microsoft Connect. A script block $ScriptBlock passed in a module function may be invoked as

. $MyInvocation.MyCommand.Module $ScriptBlock

In this case $ScriptBlock operates in the current scope.

Scripts