Variables may be declared in a number of different scopes. The scopes are:
- Local
- Global
- Private
- Script
- A numeric scope relative to the current scope
More about scopes:
The help document, About_Scopes (Get-Help about_Scopes), has more examples and detail.
The help document, About_Scopes (Get-Help about_Scopes), has more examples and detail.
By default, variables are placed in Local scope. Access to variables is hierarchical: a child (scopes created beneath a parent) can access variables created by the parent (or ancestors).