Skip to content

Latest commit

 

History

History

Function-parent-scope

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Function parent scope

If a module function creates a variable in the parent scope then the variable is created in the module scope, not necessarily the calling scope.

  • Module1.psm1 exports the function New-Variable1 which creates a variable in the parent scope.
  • Test-Module1.ps1 calls New-Variable1 and fails to get the variable Variable1 in the current scope.

If a script function creates a variable in the parent scope then the variable is created in the calling scope.