I am new to Powershell and I have noticed something that I can't quite understand.
Given two scripts:
#Script 1
$test = "This is a test"
& ".\script2.ps1"
#Script 2
Write-Host $test
When I run script1 "This is a test" is printed.
My question is: why can script2 see the variable defined in script1 when the variable isn't defined as global?
The only reason I can think of is that script2 isn't called but just imported by '&' but I'm not sure this is corret.