July 2018
Beginner
552 pages
13h 18m
English
PowerShell utilizes multiple scopes that you should be aware of when scripting. Usually, there is no need to interact with them, as PowerShell handles scoping automatically. The following scopes can be used:
|
$global: |
The outermost scope. Visible in all child scopes. |
|
$script: |
Child scope of global, and the outer scope of a script. |
|
$local: |
Child scope of script, and the outer scope of a script block. |
|
$private: |
A scope that is not visible in any child scopes. |
|
$using: |
A special scope that allows for accessing data from within remote sessions. |
$inGlobalScope = 'global'$private:NoOneShallSeeMe = 'hidden'function ChildOfGlobal{ # can read outer variables that are not private Write-Host "Outer variable value: ...Read now
Unlock full access