Variables may be declared in a number of different scopes. The scopes are as follows:
- Local
- Global
- Private
- Script
- A numeric scope relative to the current scope
More about scopes
The help document, about_scopes (Get-Help about_scopes), contains further examples and details.
The help document, about_scopes (Get-Help about_scopes), contains further examples and details.
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). Variables created in a child scope cannot be accessed from a parent scope.