Skip to content

Latest commit

 

History

History
16 lines (11 loc) · 793 Bytes

File metadata and controls

16 lines (11 loc) · 793 Bytes

How to set a variable in the caller scope

Sometimes a function should set a variable in the caller scope. The way to do this depends on how this function is defined and imported.

Functions defined in scripts may use straightforward Set-Variable -Scope 1. This way is not working in module functions.

Functions defined in modules may use less obvious $PSCmdlet.SessionState.PSVariable.Set(). This way is not working in script functions.

Scripts