Scope

suggest change

The default scope for a variable is the enclosing container. If outside a script, or other container then the scope is Global. To specify a scope, it is prefixed to the variable name $scope:varname like so:

$foo = "Global Scope"
function myFunc {
    $foo = "Function (local) scope"
    Write-Host $global:foo
    Write-Host $local:foo
    Write-Host $foo
}
myFunc
Write-Host $local:foo
Write-Host $foo

Output:

```
Global Scope
Function (local) scope
Function (local) scope
Global Scope
Global Scope
```

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Variables in PowerShell:
* Scope
* Arrays

Table Of Contents
1 Loops
14 Variables in PowerShell
19 XML
22 Strings
25 Aliases
47 MongoDB
65 AWS S3