Skip to content

Latest commit

 

History

History

Script-block-scope

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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